Hi,
I got it to work with two changes. First, I replaced the double quotes with
single quotes. Then I removed the space from "User Alert" in your call to
openCenteredWindow("","User Alert", 100, 400).
Here is the new code which works on my machine.
string message = "hello";
string s = null;
s += "<script>";
s += " function openCenteredWindow(url, name, height, width, parms){";
s += " var left = Math.floor( (screen.width - width) / 2);";
s += " var top = Math.floor( (screen.height - height) / 2);";
s += " var winParms = 'top=' + top + ',left=' + left + ',height='
+ height + ',width=' + width;";
s += " if (parms) { winParms += ',' + parms; }";
s += " var win = window.open(url, name, winParms);";
s += " win.document.write('" + message + "');";
s += " if (parseInt(navigator.appVersion) >= 4)
{win.window.focus(); }";
s += " return win;";
s += " }";
s += " openCenteredWindow('','No_Spaces', 100, 400);";
s += "</script>";
Page.RegisterStartupScript("UserAlert", s);
Thank you, Mike
Microsoft, ASP.NET Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.
This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
From: "TdJ" <pl*********@list.com>
Subject: ASP embedded jscript in asp code won't compile / run
Date: Wed, 12 Nov 2003 15:04:08 -0000
Lines: 51
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <Oj**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: host81-130-55-116.in-addr.btopenworld.com 81.130.55.116
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:190357
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
Hi guys,
I am trying to build a dialog box that does the same as an "alert" but
with out the exclamation mark graphic (which is causing some users to think
something has gone wrong !?
I have included my code, the problem is obviously the fact the jscript
'key words' are in quotes, I have tried replacing them with single quotes " ' "
and that lets me build but doesn't produce a popup.
Any Suggestions??
thanks
tom
=================
string message = SessionState.State.ExtractMessageForUser();
if (message.Length >0 )
{
// the old alert
//Page.RegisterStartupScript("UserAlert", "<script>alert('" + message
+ "');</script>");
string s = null;
// Start JScript for User Alert Box
s += "<script>";
s += " function openCenteredWindow(url, name, height, width, parms)
{";
s += " var left = Math.floor( (screen.width - width) / 2);";
s += " var top = Math.floor( (screen.height - height) / 2);";
s += " var winParms = "top=" + top + ",left=" + left +
",height=" + height + ",width=" + width;";
s += " if (parms) { winParms += "," + parms; }";
s += " var win = window.open(url, name, winParms);";
s += " win.document.write('" + message + "');";
s += " if (parseInt(navigator.appVersion) >= 4) {
win.window.focus(); }";
s += " return win;";
s += " }";
s += " openCenteredWindow("","User Alert", 100, 400);";
s += "</script>";
Page.RegisterStartupScript("UserAlert", s);
}
// call base prerender
base.OnPreRender(e);
====================