我要在客户端弹出确认和取消对话框,用messagebox但是他总也在服务器端弹出我应该怎么做啊!才能在客户端显示阿!
我是新手!请多多指教!

解决方案 »

  1.   

    Page.RegisterStartupScript("mgbox","<script language=javascript>alert('dfsa!');</script>");
      

  2.   

    button.attributes.add("onclick","return confirm('the message you need to show');")
      

  3.   

    我的代码是这样的:
    If MessageBox.Show(strMsg, strMsg,_
     MessageBoxButtons.YesNo,_
     MessageBoxIcon.Exclamation,_
     MessageBoxDefaultButton.Button1,_
     MessageBoxOptions.RightAlign) = DialogResult.Yes Then
        **********
        **********
    End If   
    我想以同样的方式,但是弹出的对话框是在客户端的!
      

  4.   

    你这是C\S结构的东西
    在Windows程序上行的通
    在Web上就不行了
      

  5.   

    用javascript可以实现.
    给你一个例子.
    在.cs代码中编写
    string Action = (Request.QueryString["Action"]!=null)?Request.QueryString["Action"].ToString():"1";
    if(Action=="1")
    {
    Response.Write("<script language=javascript>window.close();</script>");
    }
    if(Action=="2")
    {
    Server.Transfer("UILogon.aspx");
    }在页面中编写
    <script language="javascript">
    function ComfirmExit(action){
    if(action==1)
    {
    myconfirm = confirm("确实要关闭窗口,退出报表管理系统吗?");
    if (myconfirm==true){
    top.location.href="logout.aspx?Action=1";
    }
    }
    if(action==2)
    {
    myconfirm = confirm("确实要注销吗?");
    if (myconfirm==true){
    top.location.href="logout.aspx?Action=2";
    }}
    }
    </script><A onclick="ComfirmExit(2)" href="#" class="label" target="_self">注销</A>&nbsp;&nbsp;&nbsp;&nbsp;
    <img src="./images/exit.gif"> <A onclick="ComfirmExit(1)" class="label" href="#" target="_self">
    退出</A>
      

  6.   

    Response.Write("<Script language=Javascript>");
    Response.Write("alert('数据保存成功!');");
    Response.Write("</script>");
      

  7.   

    Response.Write("<script language='javascript'>var ans;");
    Response.Write("ans=window.confirm('新增成功! 是否回到查詢頁面 ?');");
    Response.Write("if (ans==true){window.location.href='WebForm5.aspx'}</script>");
    Response.Write("</script>");
      

  8.   

    如果是这样的话我还得在page_load里做session变量的传值和判断是不是
      

  9.   

    给你两个 
             using System;
    using System.Text;
    using System.Web; /// <summary>
    /// 在Web页面上显示可包含文本和按钮(通知并指示用户)的消息框。
    /// </summary>
    public class WebMessageBox
    {         
                      
                      /// <summary>
    /// 显示具体消息的消息框,并执行history的回退。
    /// </summary>
    /// <param name="text">显示具体消息。</param>
    /// <param name="pos">回退的步数。</param>
    public static void Show(string text,int pos)
    {
    StringBuilder sb = new StringBuilder("<script language=\"javascript\">");
    sb.Append("alert('").Append(text).Append("');");
    sb.Append(" window.history.go(" + pos+ ");");
    sb.Append("</script>"); HttpContext.Current.Response.Write(sb.ToString());
    HttpContext.Current.Response.End();
    }
    public static void Alert(string text)
    {
    StringBuilder strBuilder = new StringBuilder("<script language=\"javascript\">");
    if (text != String.Empty)
    strBuilder.Append("alert('").Append(text).Append("');");
    strBuilder.Append("</script>"); HttpContext.Current.Response.Write(strBuilder.ToString());
    HttpContext.Current.Response.End();
    }
    }
      

  10.   

    http://www.developerfusion.com/utilities/convertvbtocsharp.aspx