日期:2014-05-18  浏览次数:20534 次

使用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 是正解~