Manoj
Manoj

Reputation: 11

How to set Position of alert messege in asp.net

Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "JavaScript:alert('MY Message')", true);

Above code shows message box on top of the page , but I want it to the center of the page.

Upvotes: 1

Views: 1666

Answers (2)

Bhalchandra K
Bhalchandra K

Reputation: 2681

The alert('message') is dialog box shown by browser, with very little to no control over its positioning.

Instead you can use jquery ui dialog to show your message. There are 'n' number of jquery plugins which are available to show the alert messages. And of course you can control the positioning dialogs of these custom dialogs.

  1. http://jqueryui.com/dialog/
  2. http://needim.github.io/noty/
  3. http://jquery-plugins.net/tag/alert-box

Upvotes: 1

Abijeet Patro
Abijeet Patro

Reputation: 2884

Alert boxes by default open at the center. Look at @Tomzan's comment, you are probably getting it at the top for just Chrome.

As far as I know it's not possible to make any modifications to that. If you want a custom alert box look into using jQuery ui. It'll allow you to put a messagebox wherever you want.

jQuery ui dialog box

Upvotes: 1

Related Questions