开发者

How to show messageBox/ alert in asp.net?

开发者 https://www.devze.com 2023-02-15 07:08 出处:网络
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.

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");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号