Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 25th, 2003, 12:35 PM
Registered User
 
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default message boxes

I'm trying to write some code in my ASP.NET C# 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);

 
Old November 25th, 2003, 12:55 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

A. This doesn't look right:
switch (Convert.ToString(Request.QueryString"action"))
shouldn't it be
switch (Convert.ToString(Request.QueryString["action"]))

B. What is strSerial?

C. sScript = "<script type=\\"text/javascript\\">";
don't you want only one \. Doesn't \\ escape the \?

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 26th, 2003, 04:35 AM
Registered User
 
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

A. This was just a cut and paste error, my actual code reads it should :

switch (Convert.ToString(Request.QueryString["action"]))

B. I missed out strSerial on the post :

strSerial = Convert.ToString(Request.QueryString["serial"]);

C. I'm not sure whether I need to use \\ or \, but it doesn't work either way!


Mike









Similar Threads
Thread Thread Starter Forum Replies Last Post
message boxes kdhessler VB.NET 2002/2003 Basics 10 May 9th, 2005 08:52 AM
Message Boxes and passwords jackdaddy Javascript How-To 5 November 27th, 2004 11:24 PM
Formatting Message Boxes Magic_Hat Excel VBA 1 June 21st, 2004 10:13 AM
Customizing Javascript Message boxes pvasudevan Javascript How-To 1 April 19th, 2004 10:19 AM
How to I create non-modal message boxes? Ciarano VB How-To 0 March 12th, 2004 12:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.