efrat
efrat

Reputation: 11

How to show messageBox/ alert in asp.net?

How can i show a messageBox in my asp.net page? (i write with c#) whice lines i need to write?

Upvotes: 0

Views: 11862

Answers (5)

boruchsiper
boruchsiper

Reputation: 2038

write the following on the event of your choosing:

Interaction.MsgBox("Your Text Goes Here");

Upvotes: 0

Javed Akram
Javed Akram

Reputation: 15354

Use javascript

Button1.Attributes.Add("onclick","alert('Hello World!!!');");

Upvotes: 0

Brian Mains
Brian Mains

Reputation: 50728

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.

Upvotes: 1

Robbie Tapping
Robbie Tapping

Reputation: 2556

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.

Upvotes: 1

Bala R
Bala R

Reputation: 109037

You can try something like this.

 protected void Page_Load(object sender, EventArgs e)
 {
      Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "test", "<script>alert('hi');</script>");
 }

Upvotes: 3

Related Questions