TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > C#(C Sharp)

Notices

Reply
 
Thread Tools Display Modes
Old 15-12-2007, 09:59 AM   #1
Jonathan Wood
Guest
 
Posts: n/a
Re: Escape Sequences

Peter,

> The following code shows the ending </script> tag in a non-string color
> in the editor, and the line produces the error "Newline in constant."
>
> string jScript = "<script>document.forms[0].submit();</script>";
>
> Is this a bug? When did "</" become a string escape sequence?


Works fine on my computer. Are you sure that's exactly the string you're
using? Did you copy and paste it directly from your IDE? What IDE and
version are you using?

I was afraid of that. I recently installed VS2008 Pro and the string above
was definitely copied and pasted from the editor.

Here's a bit more of my code. I guess I should have pointed out this code is
part of an ASP.NET master page, although I didn't expect that would matter:

<script runat="server">

void Page_Load()
{
if (!Page.IsPostBack)
{
litYear.Text = DateTime.Now.Year.ToString();

string jScript = "<script>document.forms[0].submit();</script>";
}
}

// ...

If I change the line to:

string jScript = "<script>document.forms[0].submit();<//script>";

The string is treated as a single string as expected.

This is obviously a bug and, apparently, related to ASP.NET.

> The error you're seeing usually happens when you do in fact have a newline
> in the constant. That is, the literal is actually being split across two
> lines. It makes me wonder if your code does in fact look like what you
> posted.
>
> Remember: if you don't post _exactly_ what you're using that causes an
> error or other problem, there's no way for someone to actually help.


Yes, I'm not new to programming or, as an MVP, unaware of the issues that
arise trying to help people.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

  Reply With Quote
Reply

Thread Tools
Display Modes


Google
 


All times are GMT +5.5. The time now is 05:27 AM.


vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2008, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional