windows应用程序中是 MessageBox.Show()
web应用程序中的对话框的代码应该怎么写?

解决方案 »

  1.   

    alert()
    confirm()
    prompt()
    你自己上网搜一下这三个方法的应用
      

  2.   

    public void MessageBox(string strMsg)
    {
    Response.Write("<script>alert('" + strMsg + "')</script>");
    }
      

  3.   

    public static void MessageBox(string msg)
    {
    msg = msg.Replace("\n","\\n");
    msg = msg.Replace("'","\'");
    Response.Write("<script>alert('" + strMsg + "');</script>");
    }
      

  4.   

    /// <summary>
    /// 该函数用于通过调用javascript脚本来显示信息
    /// </summary>
    /// <param name="strMessage">>需要显示的信息</param>
    /// <param name="objUrl">需要跳转的页面</param>
    public static void ShowMessage(string strMessage,object objUrl)
    {
    System.Web.HttpContext.Current.Response.Write("<script language=javascript>");
    if(objUrl!=null)
    {
    System.Web.HttpContext.Current.Response.Write("window.location='");
    System.Web.HttpContext.Current.Response.Write(objUrl.ToString());
    System.Web.HttpContext.Current.Response.Write(@"';");
    }
    System.Web.HttpContext.Current.Response.Write("alert('");
    System.Web.HttpContext.Current.Response.Write(strMessage);
    System.Web.HttpContext.Current.Response.Write(@"');");
    System.Web.HttpContext.Current.Response.Write("</script>");
    }