473,473 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ASP embedded jscript in asp code won't compile / run

TdJ
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);
====================
Nov 17 '05 #1
1 1353
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);
====================


Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John Bentley | last post by:
Note this is crossposted to comp.lang.javacript and microsoft.public.dotnet.scripting. After some Googling and FAQing my understanding of these terms is, crudely: Javascript (3 different...
6
by: Roger | last post by:
......ie in my application! Basically I want to add a scripting language to a cross platform application. The prime requirements are that it is: a) Small b) May be easily staticlly compiled...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
2
by: CGuy | last post by:
Hi, I need to use the Eval function of JScript in my C# code. I was thinking that I could write this as a seperate JScript.NET file, compile it as a .NET module and then later link it with my C#...
4
by: Jon Rista | last post by:
I have a project where I need to create a windows .exe by compiling code and linking in some resources. This program thats being generated is somewhat unconventional, and I'll explain how. I'm...
5
by: Captain Dondo | last post by:
I am working on an embedded platform which will serve a small number of dynamic webpages. Right now we are looking at php+javascript with apache as the webserver. Do we need to compile the...
6
by: Giulio Petrucci | last post by:
Hi there, as I need to share a .NET context with a JavaScript context and I can't re-write Rhino in C# ;-) I'trying to understand something about the Microsoft.JScript namespace, but - really -...
1
by: Andrew Wan | last post by:
How can VBScript code access JScript code variables in the same ASP page? <SCRIPT LANGAUGE="VBScript"> Dim a a = 10 </SCRIPT> <SCRIPT LANGUAGE="JScript"> Response.Write(a); </SCRIPT>
30
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Let's say we had a simple function for returning the amount of days in a month: unsigned DaysInMonth(unsigned const month) { switch (month) { case 8: case 3: case 5:
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.