请问在ASP.NET里面怎么用MessageBox????
请大家赐教MessageBox的具体用法

解决方案 »

  1.   

    下面提供一段示例代码,演示在aspx中使用client端的javascript,在web方式下弹出提示框的就象在windows下的MessageBox,供您参考:
    <html>
    <head></head>
    <body>
    <form id="Form1" method="post" runat="server"> 
    <asp:Button id="Button1" runat="server" Text="Button" onClick="Button1_Click"> 
    </asp:Button>
    </form>
    </body>
    </html><script language="c#" runat="server">
    void Page_Load(Object Src, EventArgs E)
    {
     Button1.Attributes.Add("onclick", "return confirm('Are you sure you wish to delete this item?');");
    }
    void Button1_Click(Object Src, EventArgs E)
    {
     Response.Write("Button1_Click");

    </script>Button1按钮同时相应客户端的javascript指令和服务器端的Button1_Click事件。
      

  2.   

    楼上的说得对.但是用我的方法可以在客户端调用javascript,并获取其返回值,进行类似WINFORM MessageBox 处理
      

  3.   

    脚本JAVASCRIPT
    Response.Write("<script>window.alert('你想干什么');</script>");
      

  4.   

    客户端用js的话有alert,服务器端没有.
    alert的用法楼上很多了,我就不说了
      

  5.   

    强烈建议使用
    Response.Write("<script defer>window.alert('你想干什么');</script>");
    这样弹出的窗口不会出现白屏,而且能夺取焦点啊
      

  6.   

    //----------------------------------------------------
    public void MessageBox(string strText ,Page objPage)
    {
    /* 1、编写:
    *  2、功能:在客户端弹出对话框
    *  3、参数:string strText 对话框的文本信息;Page objPage 对话框的所在页面
    *  4、返回值: 无
    *  5、用途:提示用户操作是否合法,应如何进行下一步操作
    */
    string IidScript,strWindow;
    strWindow="window.alert('"+strText+"')";
    IidScript = "<script>"+strWindow+"</script>";
    objPage.RegisterClientScriptBlock("failure",IidScript);
    }//调用事例
    //MessageBox("提示内容",Page)//其中Page是永远不变的。
      

  7.   

    做WEB开始,结合客户端脚本的应用很重要。显示客户端对话框有几种方法:
    一、直接输出代码:
    response.write("<script>window.alert('这是一个对话框!');</script>");
    二、注册一个脚本到客户端:
    registerclientscript("Message","<script>window.alert('这是一个对话框!');</script>");
    三、注册一个控件的html属性,在执行服务器控件之前执行一段客户端脚本:
    button btn = new button();
    btn.attributes["onClick"]="confirm('您确定吗?');";
      

  8.   

    感谢各位兄弟的帮助
    请问,可以放在CodeBehind里面吗?
    还有就是麻烦一下大家给我讲解一下客户端脚本,和服务器端脚本的区别
      

  9.   

    放在CodeBehind里是一样的啊
    Attribute.aspx
    <%@ Page language="c#" Codebehind="Attribute.aspx.cs" AutoEventWireup="false" Inherits="WebApplication2.Attribute" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML> <form id="Form1" method="post" runat="server">
    <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 112px; POSITION: absolute; TOP: 64px" runat="server"
    Text="Button"></asp:Button>
    </form></HTML>Attribute.aspx.cs
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace WebApplication2
    {
    /// <summary>
    /// Attribute 的摘要说明。
    /// </summary>
    public class Attribute : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Button Button1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    Button1.Attributes.Add("onclick","return confirm('Are You Sure?');"); } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void Button1_Click(object sender, System.EventArgs e)
    {
    Response.Write("Button1_click");
    }
    }
    }
      

  10.   


    private void Page_Load(object sender, System.EventArgs e)
    {
    btnLink.Attributes.Add("onclick","return confirm('Are You Sure?');");
    if(!Page.IsPostBack)
    {
    dgrdLinkview.DataSource=objLink.viewLink();
    dgrdLinkview.DataBind();
    }
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {    
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void btnLink_Click(object sender, System.EventArgs e)
    {
    if(Page.IsValid)
    {
    Response.Write("btnLin_Click");
    objLink.addLink(txLinkname.Text,txLinkmemo.Text,txLinkurl.Text);
    txLinkname.Text="";
    txLinkmemo.Text="";
    txLinkurl.Text="";
    }
    }这样写对吗?
      

  11.   

    这也要人讲解,书上多的是。csdn上难道都是闲人啊,专门替你答问的?问问题前先自己查查资料,查不出资料到网上搜索一下答案。找不到答案了再来问啊。