ispostback 按网页上的刷新按纽!ISPOSTBACK里面的代码就会运行一次呀?请问什么原因是?有什么方法让他不访问吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 IsPostBack只是判断当前的访问是不是Postback IsPostBack代表是否页面回传,如果是回传的话,就不在向服务器提交已经显示的内容 把代码写道if (!IsPostBack){ 这里写代码} 在程序中写:protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { } }就不会出现你说的那种情况了. 这个是.net postback 机制的问题你每执行一次post提交后 如果没有转向到别的页面 使用IE刷新按钮 就会重新回发刚才的post请求你可以 用一个 值Session["isBack"]或是cookie来判断 是否已经执行了提交也可以提交后转向到别的页面或Response.Redirect("你当前的页面", true);或者 禁用客户端缓存protected void NoCatchOutPage() { HttpContext.Current.Response.Buffer = true; HttpContext.Current.Response.Expires = 0; HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1); //DateTime.Now.AddDays(-1); HttpContext.Current.Response.AddHeader("pragma", "no-cache"); HttpContext.Current.Response.AddHeader("cache-control", "private"); HttpContext.Current.Response.CacheControl = "no-cache"; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetAllowResponseInBrowserHistory(true); }你的PageLoad里面 第一行 调用这个 函数 按网页上的刷新按纽!ISPOSTBACK里面的代码就会运行一次呀-------------------------------------------------------------IE上的刷新,等于重新访问一次页面,!ISPOSTBACK意思是“不是服务器控件postback”,正好满足你的条件,肯定会执行了.把!去掉就行 if(!IsPostBack) { } 关于ASP.NET的DataList,求高手解决 MVC中Controller取View中控件的问题 同时生成单据和单据明细,如何插入数据库? div+css 在DataGrid中的问题 asp.net页面做好了,一部分机子能正常访问,有一部分机子访问就出错,WHY? button1触发button2事件 菜鸟来报到!!!!散分! asp.net实现文件下载功能! Gridview 中:HyperLinkField如何改名? 基础连接已经关闭: 无法解析此远程名称。 SQL中的空值问题 帮帮忙 谢谢
if (!IsPostBack)
{
这里写代码
}
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{ }
}
就不会出现你说的那种情况了.
你每执行一次post提交
后 如果没有转向到别的页面 使用IE刷新按钮 就会重新回发刚才的post请求你可以 用一个 值Session["isBack"]或是cookie来判断 是否已经执行了提交
也可以提交后转向到别的页面或Response.Redirect("你当前的页面", true);
或者 禁用客户端缓存protected void NoCatchOutPage()
{
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Expires = 0;
HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1); //DateTime.Now.AddDays(-1);
HttpContext.Current.Response.AddHeader("pragma", "no-cache");
HttpContext.Current.Response.AddHeader("cache-control", "private");
HttpContext.Current.Response.CacheControl = "no-cache";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetAllowResponseInBrowserHistory(true);
}你的PageLoad里面 第一行 调用这个 函数
-------------------------------------------------------------
IE上的刷新,等于重新访问一次页面,!ISPOSTBACK意思是“不是服务器控件postback”,正好满足你的条件,肯定会执行了.把!去掉就行
{ }