An easy one for you guys. The following page refuses to parse ampersands correctly. Everytime an ampersand is seen it is replaced by & which is all very well but I just want "nmouseover=javasript:this.src=someurl?somquerystring=somequerystringproperty&otherquerystring=someotherproperty"
Help much appreciated. <script runat="server"> sub page_load(sender as object, e as eventargs) ml.attributes("onmouseover")="Javascript:this.src = 'someurl?somequerystring&somequerystringproperty&otherquerystring=someotherproperty end sub' </script> <form
runat="server"> Label </form>
Everytime an ampersand is seen where? If you are using this code, then it is just shown on screen as "...&...&...," but in the code it is still &. Those character replacements are made so that you can show them in HTML code and at the same time not have their
original intent (i.e., " will" only display one space infront of will, but there are 3, so to show them (on your own site, not here) you would use ). I think you understand that. Also, I do not think you generally need the "Javascript:" name in place. Anyway,
just try doing this:
It is also a welcome happening for browsers when it comes across & in query strings (it understands that as &, and we are actually supposed to code that way, but it is definitely not friendly looking... oh well).
Thanks for the reply. The point i was making is that on the source code of the page sent to the browser i get the following: someurl is an aspx which response.outputs an image file based on a variety of querystring properties e.g. a passed url. What I need
is the following output: You say that it is a welcome happening for a browser to come across & in querystrings. But, if you write the following code in thispage.aspx: SOMELABEL.text = request.querystring("id").tostring() and go to: roundedimagerollover.aspx?map=england&id=3
the label will not show 3 but an error will occur (the querystring item is actually "amp;id"). Any help much appreciated
Well, it should be welcome as it was a standard, at least at some point (an incrediblely idiotic standard I might add). Just so that you know, you do not need to do Request.QueryString("blahblahblah").ToString() as it returns a string anyway. You're giving
way to an error if you do ToString() (null [Nothing] reference). I guess the only question that I have now is how is the Javascript OnMouseOver event code formed? That's where the problem must be. ASP.NET shouldn't mess with source code unless you tell it
too.
As I said in the first post, here is the code that creates the incorrect attribute (with & replcaed for ampersands) <script runat="server"> sub page_load(sender as object, e as eventargs) ml.attributes("onmouseover")="Javascript:this.src = 'someurl?somequerystring&somequerystringproperty&otherquerystring=someotherproperty
end sub </script> <form runat="server"> </form>
Extremely odd, I have never come across this problem, but now that you mention it I definitely notice it. I'm still looking for a flag to pass along to eliminate encoding, but until then I guess you'll have to mess with it so that you add the character 38 (&),
so that it cannot replace it. "this.src='mysite.aspx?blah=x'+String.fromCharCode(38)+'blah2=y'+String.fromCharCode(38);" --- I checked this on one of my sites where my pictures involve dynamic settings through query strings and this is not a problem. The pictures
load the same and it does in fact put in & inside my links as well (singlepic.aspx?sid=2&sub=12&pic=2 is my output). I am not technically sure why it does this encoding without a way to stop it (other than maybe by inheriting and overwriting the Render method,
but that seems extreme for something this simple), but in either event it does not seem to have effect for me (I have tested my site in most browsers, including backwards to Opera).
woodced
Member
15 Points
3 Posts
ampersands in control attributes
May 23, 2003 07:25 PM|LINK
pickyh3d
Star
9696 Points
1955 Posts
Re: ampersands in control attributes
May 23, 2003 08:24 PM|LINK
ml.attributes("onmouseover")="Javascript:this.src = 'someurl?somequerystring&somequerystringproperty&otherquerystring=someotherproperty';"It is also a welcome happening for browsers when it comes across & in query strings (it understands that as &, and we are actually supposed to code that way, but it is definitely not friendly looking... oh well).woodced
Member
15 Points
3 Posts
Re: ampersands in control attributes
May 23, 2003 08:54 PM|LINK
pickyh3d
Star
9696 Points
1955 Posts
Re: ampersands in control attributes
May 24, 2003 01:46 AM|LINK
woodced
Member
15 Points
3 Posts
Re: ampersands in control attributes
May 24, 2003 08:24 AM|LINK
pickyh3d
Star
9696 Points
1955 Posts
Re: ampersands in control attributes
May 25, 2003 02:57 AM|LINK
chopps
Member
586 Points
158 Posts
update
Aug 01, 2003 03:28 PM|LINK