之间有什么客户端浏览器的提交机制和ASP.NET回发机制有什么区别? [英] What is the difference between client browser's submit mechanism and the ASP.NET postback mechanism?

查看:104
本文介绍了之间有什么客户端浏览器的提交机制和ASP.NET回发机制有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.usesubmitbehavior.aspx\"相对=nofollow> Button.UseSubmitBehavior财产用于获取或设置Button控件是否使用客户端浏览器的提交机制还是ASP.NET回发机制的值。

Button.UseSubmitBehavior property is used to gets or sets a value indicating whether the Button control uses the client browser's submit mechanism or the ASP.NET postback mechanism.

那么,有什么区别客户端浏览器的提交机制和ASP.NET回发机制有什么区别?

So, What is the difference between client browser's submit mechanism and the ASP.NET postback mechanism?

推荐答案

如果您设置使用行为提交为false,ASP.NET会生成脚本来处理,通过调用像下面的code__doPostBack的方法提交。该方法将增值事件目标告诉服务器哪一个元素火当前的事件。

If you set use submit behavior to false, ASP.NET will generate script to handle submit by calling "__doPostBack" method like the following code. The method will add value to event target for telling server which element fire current event.

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['ctl00'];
if (!theForm) {
    theForm = document.ctl00;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>

<input type="button" name="Button1" value="Submit" onclick="javascript:__doPostBack('Button1','')" id="Button1">      

在另一方面,如果设置使用行为提交为true,ASP.NET会生成按钮,输入类型提交的,而不是类型的按钮。使用时点击这个按钮,表单将正常submited。

In the other hand, if you set use submit behavior to true, ASP.NET will generate button as input type submit instead of type button. When use click this button, the form will be normally submited.

<input type="submit" name="Button1" value="Submit" id="Button1">

这两种方法都没有在服务器端的差异。但是,如果你使用的设置提交行为属实,这将产生一个有点清洁XHTML。

Both ways are not difference at the server-side. But if you set use submit behavior to true, it will generate a bit cleaner XHTML.

这篇关于之间有什么客户端浏览器的提交机制和ASP.NET回发机制有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆