troubleshooting Question

Explain solution :Code does a postback even tho Javascript returns false

Avatar of Camillia
CamilliaFlag for United States of America asked on
11 Comments1 Solution493 ViewsLast Modified:
This is the solution (seems like it) to my issue below but I dont know how to implemet it. If you scroll down, the developer explains a hidden field

I have the code below and I put "alert" and I get "false" when I cancel the popup msg. It should just cancel and not call the code but not sure why it's calling the code. This is what I have:

protected void lvOutgoing_OnItemDataBound(object sender, ListViewItemEventArgs e)
        chkResponseLetter.Attributes.Add("onclick", "rdoClick(" + lblPatientId.Text + "," + lblToHCProvider.Text + ")");


<asp:CheckBox runat="server" AutoPostBack="true"  OnCheckedChanged="chkResponseLetter_checked" title="Check if you have received a Response letter"  ID="chkResponseLetter" />


<script type="text/javascript">
         function rdoClick(click, toHCProviderId) {
                         var msg = confirm("Have you verified you have received the Response letter?");
             alert(msg); //*** I get false here

             if (msg) {//if yes Clicked

                // do whatever

                 return true;
                 return false;



I tried this but with this...when user clicks on cancel...there's no post back. BUT, it breaks the "ok" functionality. Even when OK is clicked, there's no post back but there should be when user clicks ok

chkResponseLetter.Attributes.Add("onclick", "return rdoClick(" + lblPatientId.Text + "," + lblToHCProvider.Text + ")");

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros