How can i show a messageBox in my as开发者_如何转开发p.net page? (i write with c#) whice lines i need to write?
You can try something like this.
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "test", "<script>alert('hi');</script>");
}
in ASP.NET there is no direct control like in winforms for Message Boxes. You can download the ASP.NET toolkit and use the ModalPopupExtender and then create your own MessageBox.
Or.. You can use javascript in your ASP.NET page to show an Alert using Javascript.
You have to use JavaScript to do this, by using Page.ClientScript.RegisterStartupScript
or RegisterClientScriptBlock
to call the client-side alert("this is my messagebox");
JS method.
You can also use AJAX control toolkit ModalPopupExtender, or JQuery's dialog component.
HTH.
Use javascript
Button1.Attributes.Add("onclick","alert('Hello World!!!');");
write the following on the event of your choosing:
Interaction.MsgBox("Your Text Goes Here");
精彩评论