473,503 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

message boxes

I'm trying to write some code in my Page_Load where the user can click
OK or Cancel in a message box to decide whether they want to be
redirected or not. If the user clicks OK, then they will be redirected,
if they click Cancel, then they will be sent back to the previous page.

The error that I am getting is 'newline in constant' at the part where I
am creating the sScript string.

Can anybody help with this?

Cheers,

Mike
string sPage = "";
string sScript;

switch (Convert.ToString(Request.QueryString"action"))
{
case "AI":
sPage = activate_invisilink.aspx?serial=" + strSerial);
break;
case "AT":
sPage = activate_targeted.aspx?serial=" + strSerial);
break;
}

sScript = "<script type=\"text/javascript\">";
sScript += "if(confirm('this is the message for the confirm box'))
document.location.href='" + sPage + "';";
sScript += "else document.location.href='lastpage.aspx';";

sScript += "</script>";

Page.RegisterClientScriptBlock("Redirect", sScript);

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
2 1043
In your code where you construct the string
instead of using a single \, use \\. This should solve the
new line error. in C# \ is an escape character.

I hope this helps.
Kiran
-----Original Message-----
I'm trying to write some code in my Page_Load where the user can clickOK or Cancel in a message box to decide whether they want to beredirected or not. If the user clicks OK, then they will be redirected,if they click Cancel, then they will be sent back to the previous page.
The error that I am getting is 'newline in constant' at the part where Iam creating the sScript string.

Can anybody help with this?

Cheers,

Mike
string sPage = "";
string sScript;

switch (Convert.ToString(Request.QueryString"action"))
{
case "AI":
sPage = activate_invisilink.aspx?serial=" + strSerial); break;
case "AT":
sPage = activate_targeted.aspx?serial=" + strSerial); break;
}

sScript = "<script type=\"text/javascript\">";
sScript += "if(confirm('this is the message for the confirm box'))document.location.href='" + sPage + "';";
sScript += "else document.location.href='lastpage.aspx';";

sScript += "</script>";

Page.RegisterClientScriptBlock("Redirect", sScript);

*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
.

Nov 18 '05 #2
This still doesn't work. Can anybody help?

sScript = "<script type=\\"text/javascript\\">";
sScript += "if(confirm('this is the message for the confirm box'))
document.location.href='" + sPage + "';";
sScript += "else document.location.href='default.aspx'";
sScript += "</script>;";
Thanks,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

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

Similar topics

3
2830
by: Andrew Baker | last post by:
OK this has me perplexed, puzzled and bamboozled! I have a remoting service which I displayed a message box in. I then wondered what would happen if a client made a call to the service while the...
12
1911
by: jburkle | last post by:
Hello all, I am still having an issue where multiple Message Boxes are being displayed to the user from the same form at one time. This issue hides the boxes behind the forms since the forms take...
5
3883
by: HowardChr | last post by:
I have my program set up so that when a button called "Clear" is clicked, it clears all Yes/No fields from a seperate table. The problem is that when that button is clicked, it is coming up with 2...
2
4490
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message...
8
12343
ADezii
by: ADezii | last post by:
Have you ever wondered how Microsoft Access displays those Custom Message Boxes with the first line in BOLD, and the second and/or second and third lines in Normal Font Weight? The answer lies in the...
0
7287
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
7348
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5592
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
5021
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
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3175
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
3166
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
744
muto222
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.