In order to have javascript automatically “post back” an asp.net page, the function….
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
…must be included in the html of the page. But, this function is only automatically generated by asp.net when there is at least 1 control with the “AutoPostback” property set to true. So what to do if your page does not have any “AutoPostback” controls on it???....
Add this code to the Page_Load event…
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Page.GetPostBackEventReference(Me)
End Sub
This will have asp.net generate the javascript function __doPostBack so you can then call the function with this html side code…
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" Width="129px" />
</div>
<input id="Button2" type="button" value="button" onclick="__doPostBack('Button1','')" />
</form>