简体   繁体   English

ASP.NET:如果浏览器中不存在javascript,则调用代码后面的其他javascript函数

[英]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. 在asp.net页面中,如果用户浏览器支持javascript,如何调用javascript处理表单的javascript方法;如果浏览器不支持javascript,如何使用事件背后的代码。服务器页面使用jquery。 Don't know how to invoke the needed one based on the browsers javascript availability 不知道如何基于浏览器javascript可用性调用所需的

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. 创建一个执行回发并不使用JavaScript提交数据的表单,然后在“提交”按钮上设置click事件以调用您的javascript函数。 Then use e.peventDefault() and e.stopPropagation() in the click event to prevent postback. 然后在click事件中使用e.peventDefault()和e.stopPropagation()来防止回发。

You may also need to capture the enter key press event and prevent it from causing a post back as well. 您可能还需要捕获Enter键按下事件,并防止它引起回发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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