日期:2014-05-17  浏览次数:20398 次

Response.Redirect不能跳转页面,怎么解决?谢谢
 if(IsValid)
            {
                return;
            }
                string action = Request["action"];
                if (action == "addnew")
                {
                    new T_NewsTableAdapter().Insert(txtTilte.Text, txtMsg.Text, DateTime.Now);
                }
                else if (action == "edit")
                {
                    int id = Convert.ToInt32(Request["id"]);
                    var newsRow = new T_NewsTableAdapter().GetDataById(id).Single();
                    newsRow.Title = txtTilte.Text;
                    newsRow.Msg = txtMsg.Text;
                    new T_NewsTableAdapter().Update(newsRow);
                }
                else
                {
                    throw new Exception("action错误:" + action);
                }

                Response.Redirect("NewsMgr.aspx");


原来是没问题的,但我少了new T_NewsTableAdapter().Update(newsRow);编辑没更新,就试了下 if(!IsPostBack)和 if(IsPostBack),后来找出写少了new T_NewsTableAdapter().Update(newsRow)这句后,把 if(IsPostBack)删了。结果点按钮不跳转页面了。


问题就在我修改过IsPostBack,代码应该没问题,现在要怎样解决?谢谢!
            
            

------解决方案--------------------
肯定是没有运行到 Response.Redirect 的地方,当然是不能跳转了,问题在别处看着楼主。
------解决方案---