1

I am displaying a message in my ASP.NET from code-behind using this:

Response.Write("<script>alert('Hello')</script>");

When the OK button is pressed on the message box, the whole layout of the web page shifts a little towards the right direction. What is wrong? Is something else to be added?

Cipher
  • 5,894
  • 22
  • 76
  • 112

3 Answers3

1
  private void alert(string Msg)
    {

      Response.Write("<script language = 'javascript'>window.alert('" + Msg + "')</script>");

    }

try the previos method ..

if u want cool messages try the following link:

Produce "toast" messages like StackOverflow

Community
  • 1
  • 1
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
0

At the risk of getting dinged for providing an additional answer to an "answered" question, I think others coming across this question should be advised as a matter of course that hard-coding HTML strings through Response.Write in ASP.NET applications is an increasingly frowned-upon practice for precisely the reason you've observed - the page rendering emits HTML that has no way of accounting for interjected Response.Write statements, risking all manner of layout grief.

David W
  • 10,062
  • 34
  • 60
0

Could it be that the scrollbars get visible when the popup is active? It has happened a few times for me and I thought the style was getting messed up, but it was just the scrollbars becoming visible and disappearing :) They shift the page a little.

Jón Trausti Arason
  • 4,548
  • 1
  • 39
  • 46