开发者

flickering of popup window

below is my code which closes popup window on page load also i want to show the user a message box plz login well my popup window gets close but it flickers on the screen is there any way to prevent to do that.

StringBuilder sb = new StringBuilder();
sb.Append("<script>");

sb.Append("window.close();");

sb.Append("</script");

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "test", sb.ToStrin开发者_运维知识库g(), false);

MessageBox.Show("Please Sign In first...", "Login Message", MessageBoxButtons.OK, MessageBoxIcon.Question);
return;


Your code makes no sense. You're calling RegisterClientScriptBlock, so evidently you're using ASP.NET WebForms. But you're also trying to call MessageBox.Show (looks like the WinForms version). You had to go out of your way to use both those frameworks from the same code base, and there's a reason for that: they're not meant to work together.

If you're using ASP.NET, that means your C# code is running as a Windows service on the Web server machine. That means that, if a user visits your Web site, you'll try to show a dialog box on the server machine (which is in some locked server room somewhere). The visitor to your site won't see a thing on their computer. Actually, since IIS runs as a non-interactive service, I think the call to MessageBox.Show will simply be ignored.

The only code that will run on the visitor's machine is the HTML and JavaScript produced by your ASP.NET page. If you want to show a dialog box to the user, you need to use JavaScript. The simplest way is by calling window.alert().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜