Encountering Error When Doing Post-back Using __dopostback()
Solution 1:
you can use a hidden button to do this task
Button1.Attributes.CssAttributes.Add("Display","None");
after hiding the button
you can call its click function from javascript
document.getElementById('<%=Button1.ClientID%>').click();
this will call Button1_Click on server
** remember to set UseSubmitBehaviour=false
to make this work on non-IE browsers
hope that helps :)
Solution 2:
__doPostBack is not created by default. If the page does not have a control that causes a postback then ASP.NET does not create/generate this method. In your case you can force ASP.NET to generate __doPostBack by adding the following line in you Page_Load event:
ClientScript.GetPostBackEventReference(this, string.Empty);
This line will force the creation of this method.
Solution 3:
_doPostBack isn't created by default. It appears when you are adding control with autoPostBack=true or adding some grid with buttons in it. So there is no _doPostBack javascript generated in your code. If you add
<asp:DropDownListID="list"runat="server"AutoPostBack="true"><asp:ListItemText="first"></asp:ListItem><asp:ListItemText="second"></asp:ListItem></asp:DropDownList>
for instance your code will work. Don't know if it is really useful code :) however.
Post a Comment for "Encountering Error When Doing Post-back Using __dopostback()"