Hi all,
I need to fire some custom javascript validation and then submit my ASP.Net using javascript.
How do I submit the form using javascript? Thanks!
Hi all,
I need to fire some custom javascript validation and then submit my ASP.Net using javascript.
How do I submit the form using javascript? Thanks!
To do a postback via javascript you can call the following server side to create the javascript for you:
string postBackJavascript = Page.GetPostBackEventReference(yourControl);
This will return the __doPostBack
javascript as a string and you will need place on your page attached to something or you can call the __doPostBack
directly on your own with:
__doPostBack(yourControlId,'');
If your doing it yourself and not using Page.GetPostBackEventReference
then make sure to get the ClientID
for the control that triggered the validation like:
__doPostBack('<%= yourControl.ClientID %>','');
EDIT: After re-reading your question you didn't say you wanted to trigger the postback based on an ASP.NET control, you might not even be using any ASP.NET controls so in that case if you want to just do a vanilla postback you can do:
document.forms[0].submit();