当前位置: 代码迷 >> ASP.NET >> 使用Response.Write有什么限制吗?小弟我的语句为什么不能执行
  详细解决方案

使用Response.Write有什么限制吗?小弟我的语句为什么不能执行

热度:4884   发布时间:2013-02-25 00:00:00.0
使用Response.Write有什么限制吗?我的语句为什么不能执行?
我在GridView的模板列中,添加了一个按钮,点击它时,显示一个提示信息:
代码:

if (ckmx.sl > kcsl)
  {
  Response.Write(" <script> alert('出库数量不能大于库存数量!'); </script> "); //为什么出错?
  return;
  }

但不能正常显示提示信息。

在其他地方可以,为什么呢?

------解决方案--------------------------------------------------------
你的GridView是不是放在了UpdatePanle里面了.
ajax控件里不能用这个输出信息的
------解决方案--------------------------------------------------------
用AjaxExtensition
C# code
#region 弹出信息    /// <summary>    /// 利用ScriptManager和UpdatePanel时,弹出信息    /// </summary>    /// <param name="strMsg">输入字符串</param>    protected void ShowMsg(string strMsg)    {        ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.UpdatePanel1.GetType(), "", "alert('" + strMsg + "');", true);    }    #endregion
------解决方案--------------------------------------------------------
ScriptManager.RegisterStartupScript 是正解~
  相关解决方案