I need to fire some custom JavaScript validation and then submit my ASP.NET using JavaScript.
How do I submit the form using JavaScript?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To do a postback via JavaScript you can call the following server side to create the JavaScript code for you:
This will return the
__doPostBackJavaScript code as a string, and you will need place it on your page attached to something or you can call the__doPostBackdirectly on your own with:If you’re doing it yourself and not using
Page.GetPostBackEventReferencethen make sure to get theClientIDfor the control that triggered the validation, like: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: