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?
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
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.
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.
精彩评论