Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
__doPostBack Javascript not working in IE8 & Firefox Browser Not firing my event in c# Button Click Event (btnSubmit_Click)

XML
var btn = document.getElementById("<%=Button1.ClientID %>");
               btn.click();
               __doPostBack('btn', 'OnClick');




                <div style="display: none;">
                <asp:Button ID="Button1"  runat="server"  OnClick="btnSubmit_Click"/>
                 </div>



           C# Codebind

          public void btnSubmit_Click(object sender, EventArgs e)
          {
        //Code

           }
Posted

1 solution

The first argument to the __doPostBack function is the ID of the control which is causing the postback. You are passing the string 'btn', which is the name of the javascript variable, not the ID of the control.

Change your code to:
JavaScript
var btn = document.getElementById("<%=Button1.ClientID %>");
__doPostBack(btn.id, '');
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900