如果刷新页面,则会发生按钮的单击事件 [英] button's click event occurs if the page is refreshed

查看:114
本文介绍了如果刷新页面,则会发生按钮的单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的问题是,如果刷新页面,则会发生按钮的click事件.

身体可以帮助我解决这个问题吗?

谢谢.

Hi,

My issue is that button''s click event occurs if the page is refreshed.

Can body help me out in solving this problem.

Thanks.

推荐答案

我敢肯定,这根本不是真的.

您无法证明事件已发生.这可能不是事件,而仅仅是事件处理程序,可以将其编写为单独的方法:您可以从其他地方调用它.

请执行以下操作:1)找到您的事件处理程序; 2)在Visual Studio中,单击其名称上的上下文菜单,选择并单击查找所有引用";如果无法做到,请执行全文搜索.

它将找到您看到效果的原因.您找到它了吗?
I am sure, this is simply not true.

You could not proof your event occurs. This could be not event but merely your event handler which could write as a separate method: you call it from somewhere else.

Do the following: 1) locate your event handler; 2) in Visual Studio, click context menu on its name, select and click "Find All References"; If you cannot do it, perform full text search.

It will find you the reason of effect you see. Did you find it already?


感谢您的回复.

是的,它是Web应用程序.

和代码类似下面的内容

受保护的void Page_Load(对象发送者,EventArgs e)
{
//要在页面上执行的基本操作
}

受保护的无效btnUpload_Click(对象发送者,EventArgs e)
{
//其中的代码用于上传文件.
}

现在,每当刷新页面时,默认情况下都会调用btnUpload_Click并创建文件的副本.
Thanks for the reply.

Yes it is web application.

And code is some what like following

protected void Page_Load(object sender, EventArgs e)
{
// basic action to be performed on page
}

protected void btnUpload_Click(object sender, EventArgs e)
{
//Code inside this is for uploading file.
}

Now whenever I refresh my page, btnUpload_Click is called by default and it creates a copy of file.


看起来您无法清晰地表达自己的意思.看起来,一旦您使用上载按钮,然后每当您按F5键(执行刷新)时,同一事件就会再次触发(一个常见问题).
如果是这样,请查看此文章以寻求解决方法: ASP.Net中的刷新页面问题 [ ^ ]
Looks like you are unable to express yourself clearly. It looks like once you use upload button and then whenever you press F5 (do a refresh), same event triggers again (A common issue).
If so, have a look at this artilcle for workaround: Refresh Page Issue in ASP.Net[^]


这篇关于如果刷新页面,则会发生按钮的单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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