简体   繁体   中英

Calling Page Click event via User Control

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

在此输入图像描述

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.

在此输入图像描述

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..

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;
    });
});

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM