escape problem

G

Guest

I'm using asp.net c#

in my code behind I coded the following:
ButtonAsynchronous.Attributes.Add("onclick", @" setTimeout(
""UpdateImg('AnimatedProgress','images/running.gif');"" , 50); ");

This renders into:
onclick=" setTimeout( "UpdateImg('AnimatedProgress','images/running.gif');"
, 50); ;" id="ButtonAsynchronous" />

I see the quotes have been escaped, which is in this case wrong as they need
to be preserved.

How should I do this?
 
M

mnichols

I tried your sample in VS 2003 and VS 2005 and in both cases the
rendered html contained something like the following:

onclick="setTimeout("UpdateImg('AnimatedProgress','images/running.gif');"",
50); ;" id="ButtonAsynchronous" />

I think in your message and possibly mine the &quot is being changed
into a " though maybe this is a ThunderBird issue on my end.

Anyhow, regardless of the display issue, the code executed properly so I
am not sure if there is a problem?

mnichols
 
G

Guest

Mnicholas,

Indeed it's the &quot which is the problem.
In my code I use " (a double quote sign) which is being escaped.

Unfortunately in IE6 the code generates an error which it should as the
asp.net generated code is wrong.

So what should I need do to NOT escape my double quote sign?

Dan
 
M

mnichols

I think another error is causing the problem. The &quot is actually
perfect for the situation. If it were not escaped as it is, then you
would get a different error.

I gather that you are saying that IE6 is generating a javascript error
of some sort? Is it possible that there is an error in the UpdateImg
function? Try calling it without the setTimeout wrapper (maybe in the
page's onload event) and maybe you will see the other error.

Debugging code triggered by a setTimeout is tricky because VS usually
can't associate it with the original page

mnichols
 
G

Guest

mnichols,

You're absolutly correct! To verify where the error was I tried the code in
firefox, it works. I then cleared the cache in explorer and tried again,
works as well

I need to use setTimeout to reload an animated gif after form submission to
make it animate. Debugging is therefore not a problem as asp callback is
running as the setTimeout is called and the page will be overwritten with the
asp result.

Thanks for your assistance!

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top