Simple ASP.Net MessageBox?

前端 未结 3 1483
独厮守ぢ
独厮守ぢ 2021-01-16 11:42

I want a simple MessageBox for ASP.Net, but everything I tried didn\'t work and I don\'t know why. The last thing I tried was this but it didn\'t work either.

Any id

相关标签:
3条回答
  • 2021-01-16 12:22

    You could use the dialog component from jQuery UI to display a message box. A simple usage demo is available here.

    0 讨论(0)
  • 2021-01-16 12:37

    Here is your answer.

    http://www.beansoftware.com/ASP.NET-Tutorials/Message-Box.aspx

    protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
    string s = "here in button event";
                string script = "<script language=JavaScript>alert('" + s + "');</script>";
                if (!Page.ClientScript.IsStartupScriptRegistered("clientScript"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", script);
            }
    
            }
    
    
            }
    
    0 讨论(0)
  • 2021-01-16 12:38

    Is this using ajax? Is this attached to a server side event that's called when the user clicks a button?

    If so, ajax only sends data that's associated with the updatepanel in question. If so, try this ScriptManager.RegisterStartupScript((Control)ctlControl, ctlControl.GetType(), "ClientScript", "alert('foo')", true); It is important that the ctlControl is inside the updatepanel being updated.

    If you are not using ajax, is ClientScript registered elsewhere with RegisterClientScriptBlock? The client name has to be unique for every registry or it will think you are calling the same code twice.

    0 讨论(0)
提交回复
热议问题