我在.CS的pageload事件里写了一个类似hanler功能的方法,因为不想请求(AJAX)其他的页面,在这个方法里我写了一个session,在其中Response.Redirect()不起作用了,但是在判断ispostback里,session是写成功的了。求解释!
------解决方案--------------------------------------------------------
- C# code
/// <summary> /// 无消息提示(跳转页面) /// </summary> /// <param name="page">页面</param> /// <param name="jumpNum">跳转参数</param> public void ShowPage(string page, int jumpNum) { string script = ""; if (jumpNum == 0) script = "<script>setTimeout(function(){ window.location.href='" + page + "';},1000)</script>"; else script = "<script>setTimeout(function(){ parent.window.location='" + page + "';parent.closeEditor();},1000)</script>"; this.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), script); }
------解决方案--------------------------------------------------------
Response.Redirect(Request.Url.ToString());
参考http://tech.ddvip.com/2010-07/1279683335157827
------解决方案--------------------------------------------------------