问题描述
我必须点击两次提交按钮才能生成相应的事件。此btn控件不在任何更新面板中。我在button4_clck事件处理程序中使用断点进行了调试,但是在第一次单击时它不会转到该断点。然而它只在第二次点击。
以下是代码:
I have to click twice the 'submit' button to effect its corresponding event. This btn control is not within any Update Panel. I debugged using a breakpoint at button4_clck event handler but it is not going to that breakpoint on the first click. However it goes only on the second click.
Hereunder is the code:
<asp:Button ID="Button4" runat="server" CausesValidation="false"
OnClick="Button4_Click"
style="z-index: 1; left: 185px; top: 2840px; position: absolute; background-color:InactiveBorder; height:30px; width:80px; font-size:large " ForeColor="Green" Text="Submit" />
protected void Button4_Click(object sender, EventArgs e) // submit button
{
推荐答案
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<fieldset>
<legend>Label Change on Button Click</legend>
<asp:Label ID="Label1" runat="server" Text="In Heaven"/>
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
步骤:
1)添加脚本管理器
2)添加更新面板
(UpdateMode条件 - bcoz我们想要手动点击更新)
和
3)Label1是哪里我们每次点击都会发布更改...
这里的触发器
我们不需要编写EventName(通过默认系统调用默认点击方法)
这里我的按钮是Button1,UpdatePanel中的Label是Label1。
并使用UpdateProgress ....
请阅读有关特别是在哪里以及如何使用UpdateProgress(更新进度中的bcoz只能使用HTML元素 - 如果你想在后面的代码中使用那个声明的元素 - 你必须使用javascripts - 例如:中止回发)。
我已经尽力了了解你的问题和
请参考提供的参考资料,这将更有帮助。
.Net Framework 4.0和Asp.Net的版本2.
谢谢和问候,
Shrutik Panchal。
Steps:
1) Add Script Manager
2) Add Update Panel
(UpdateMode Conditional - bcoz we want to update on manual clicks)
and
3) Label1 is where we post changes on every click...
here in Triggers
we do not need to write EventName (By defaul system calls default Click method)
Here my button is "Button1" and Label in UpdatePanel is "Label1".
And to work with UpdateProgress ....
Please Read the reference about UpdateProgress particularly Programming UpdateProgress Controls in Client Script where and how to use UpdateProgress (bcoz in Update Progress you can only work with HTML elements - if you want to use that declared element in code behind - you have to work with javascripts - example: to abort post back).
I have tried my best to understand your question and
please refer to provided reference it will be more helpful.
Version of .Net Framework 4.0 and Asp.Net 2.
Thanks and Regards,
Shrutik Panchal.
这篇关于需要单击提交按钮两次才能运行事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!