I am working on a project in which I am binding Cart:

enter image description here

As shown in image I am populating my cart. Using User Control. And in User control I have populated that using One simple aspx form that is minicart. So now as you can see there is one button Checkout in That page. Which is populated through User Control but actaully its inside my minicart form. So now if I am trying to redirect using that Checkout link button. But that is not calling my click event rather its just postback the page.

enter image description here

Basically I want to call aspx page's click event through user control in my another aspx page.

I have tried to call that click event through many ways. But still page is only doing postback. I just want respose.redirect to my checkout page.

Even I have tried by using <a> also:

<a id="lnkcheckout" runat="server" href="javascript:return false;" 
      onclick="checkout_onclick">Checkout</a>

But not succeed..

有帮助吗?

解决方案

Don't go for a server side for only redirecting you can take one achor tag also

<div align="right" style="padding-top: 10px;"> <a id="lnkcheckout" href="checkout1">Checkout</a> </div>

And it will work :) I hope this will help you

其他提示

Try to use event.preventDefault() or use return false like ,

jQuery(function(){
    jQuery(document).on('click','.morebutton', function(e){
        e.preventDefault();
        alert('ok');// you code in place of alert;
    });
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top