将按钮的代码放在其他地方! [英] put the code of button somewhere else!

查看:88
本文介绍了将按钮的代码放在其他地方!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个按钮,用于检查页面是刷新还是回发。我不想使用该按钮,我想通过点击自动检测动作。可能吗?

Hi,

I have a button that checks if the page is refreshed or it is a post back. i don't want to use the button and i want to auto detect the action with out a click. is that possible?

if (ViewState["Check_Page_Refresh"].ToString() == Session["Check_Page_Refresh"].ToString())
        {
            Session["Check_Page_Refresh"] = DateTime.Now.ToString();
            TextBox1.Text = "it is not refreshed!";
        }
        else
            TextBox1.Text = "it is refreshed!";



我可以把它作为类然后调用它吗?


Can I make this as class then call it?

推荐答案

把它放在 Page_Load 事件中



解决方案1错误 - IsPostBack做了它在锡上的说法 - 检查后退不刷新。



当我看到这篇文章时,我正在检查我要发布的解决方案 - 在ASP.NET中检测刷新或回发 [ ^ ]。它说它比我更好
Put it in the Page_Load event

Solution 1 is wrong - IsPostBack does what it says on the tin - checks for Post Back NOT refresh.

I was checking the solution I was about to post when I came across this article - Detecting Refresh or Postback in ASP.NET[^]. It says it better than I could


这篇关于将按钮的代码放在其他地方!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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