需要单击提交按钮两次才能运行事件 [英] Submit Button needs to be clicked twice to run an event

查看:144
本文介绍了需要单击提交按钮两次才能运行事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须点击两次提交按钮才能生成相应的事件。此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.Net临时文件夹内容。清洁解决方案再试一次。它应该可以正常工作。



如果不共享代码。



问候,

Maheswaran.s
seems like you have cache data. Clean your ASP.Net temp folder content. Clean solution. Try run again. It should work fine.

If not share the code.

Regards,
Maheswaran.s


嘿,



我想,我可能找到了适合你的解决方案。



据我所知,你的问题是:你想要多次点击Button4(外部按钮 - 退出UpdatePanel)更新UpdatePanel的内容。



这里的参考资料可以帮到你: UpdatePanel控件简介:D



我自己尝试了你的代码:



我确实在UpdatePanel中放了一个Label,在Every Click上它将DateTime.Now()写入Label。



Hey,

I think, I may have found a solution for you.

As I understood, Your Problem Was: "You want to update contents of UpdatePanel as many times you click Button4 (External Button - out of UpdatePanel)".

here is the reference that might help you:Introduction to the UpdatePanel Control:D

I tried your code my self:

I did put a Label in UpdatePanel and on Every Click it is writing DateTime.Now() to Label.

<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 特别是编写客户端脚本中的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.


这篇关于需要单击提交按钮两次才能运行事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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