473,657 Members | 2,453 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.ToStri ng(Request.Quer yString"action" ))
{
case "AI":
sPage = activate_invisi link.aspx?seria l=" + strSerial);
break;
case "AT":
sPage = activate_target ed.aspx?serial= " + strSerial);
break;
}

sScript = "<script type=\"text/javascript\">";
sScript += "if(confirm('th is is the message for the confirm box'))
document.locati on.href='" + sPage + "';";
sScript += "else document.locati on.href='lastpa ge.aspx';";

sScript += "</script>";

Page.RegisterCl ientScriptBlock ("Redirect", sScript);

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
2 1049
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.ToStri ng(Request.Quer yString"action" ))
{
case "AI":
sPage = activate_invisi link.aspx?seria l=" + strSerial); break;
case "AT":
sPage = activate_target ed.aspx?serial= " + strSerial); break;
}

sScript = "<script type=\"text/javascript\">";
sScript += "if(confirm('th is is the message for the confirm box'))document.locat ion.href='" + sPage + "';";
sScript += "else document.locati on.href='lastpa ge.aspx';";

sScript += "</script>";

Page.RegisterC lientScriptBloc k("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('th is is the message for the confirm box'))
document.locati on.href='" + sPage + "';";
sScript += "else document.locati on.href='defaul t.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
2844
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 message box was being displayed. Since the call comes in on a different thread the client call was not blocked. This seemed to make sense to me. Next I thought, what will happen when the client calls into the server if I try to use a delegate...
12
1927
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 up the whole desktop most of the time when maximumized and also the boxes are only reachable when ALT is used. Once the multiple OK buttons are clicked the application freezes up and needs to be restarted. I have posted this before and the...
5
3887
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 seperate message boxes making sure that is what they want to do. The first one says: "are you sure you want to run that query", and the second says "You are about to update 1 row". Is there a way to code this so those message boxes are either...
2
4497
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 boxes (please see associated source code below): 1) Win32 API with context ("btnWin32WithContext_Click") 2) .NET Framework with context ("btnFrameworkWithContext_Click") 3) Win32 API withOUT context ("btnWin32WithOUTContext_Click")
8
12377
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 unique ability to break up your Message Text into either two or three Paragraphs using the "@" symbol, then evaluating the entire expression using the Eval() Function. The "@" symbol inserted into your Message Text will break the Message into...
0
8324
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
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 we have to send another system
2
1970
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.