简体   繁体   中英

ASP.NET: Call codebehind if javascript doesnt exist in browser,Else javascript function

In asp.net page, How can i call the javascript methods for form processing-submitting if the user browser supports javascript and use code behind events if the browser does not support javascript.I have the javascript code to send the form data to an ajax server page using jquery. Don't know how to invoke the needed one based on the browsers javascript availability

Create the form that does a postback and submits the data without JavaScript then set the click event on the submit button to call your javascript function. Then use e.peventDefault() and e.stopPropagation() in the click event to prevent postback.

You may also need to capture the enter key press event and prevent it from causing a post back as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM