什么webform_DoPostBackWithOptions()呢? [英] What does webform_DoPostBackWithOptions() do?

查看:586
本文介绍了什么webform_DoPostBackWithOptions()呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我宣布一个像这样的按钮:

I have a button declared like this:

<asp:Button id=Send runat="server" EnableViewState="False" 
ToolTip="Email me this report" CssClass="Button" Text="Email me this report">
</asp:Button>

但是,如果我做的浏览器检查元素,它显示是这样的:

But if I do Inspect Element in browser, it shows like this:

<input type="submit" class="Button" title="Email me this report" 
id="ctl03_Toolbar_Send" onclick="javascript:WebForm_DoPostBackWithOptions(new 
WebForm_PostBackOptions("ctl03$Toolbar$Send","", true, "", "";, false, false))" 
value="Email me this report" name="ctl03$Toolbar$Send">

我不知道onclick事件从何而来?它有什么作用?

I wonder where the onclick event comes from? What does it do?

感谢您的帮助提前。

推荐答案

如果您设置了按钮服务器控件的PostBackUrl属性,那么就意味着它是跨页投递,然后asp.net框架,而不是正常的__doPostBack()将WebForm_DoPostBackWithOptions。检查您是否有一项PostBackUrl属性设置为这个按钮。

If you set the PostBackUrl property for the Button server control, then it means it is cross page posting and then asp.net framework instead of normal __DoPostBack() adds "WebForm_DoPostBackWithOptions". Check if you have "PostBackUrl" Property set for this button.

<asp:Button id=Send runat="server" EnableViewState="False" PostBackUrl="~/Page2.aspx"
ToolTip="Email me this report" CssClass="Button" Text="Email me this report">
</asp:Button>

如果你的情况,你有没有设置一项PostBackUrl,然后ASP.NET框架也并不默认的按钮控件添加这一点,所以这意味着必须有另一个控制设置onclick属性值可能使用以下SEVER侧面code -

If in your case you have not set the "PostBackUrl", then ASP.NET framework also does not add this by default for Button Control, so this means there has to be another control setting the OnClick attribute value probably using following sever side code -

    PostBackOptions myPostBackOptions = new PostBackOptions(this);
    myPostBackOptions.ActionUrl = "Page2.aspx";
    myPostBackOptions.AutoPostBack = false;
    myPostBackOptions.RequiresJavaScriptProtocol = true;
    myPostBackOptions.PerformValidation = true;

    // Add the client-side script to the HyperLink1 control.
    Button1.OnClientClick = Page.ClientScript.GetPostBackEventReference(myPostBackOptions);

这篇关于什么webform_DoPostBackWithOptions()呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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