javascript - How do I inject a script URL containing an ampersand with ASP.NET? -


I have a server control that the program needs to inject javascript context into the page. This refers to the context of Microsoft's Bing Map, for which the & amp; to attach to the script URL for use on SSL; S = 1 is required. the problem is that. NET Framework encodes properties and & amp; Converts to and (verified with reflector). After some time that & amp; is completely deleted

The desired script tag:.

  & lt; Script type = "text / javascript" src = "https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1" & gt; & Lt; / Script & gt;  

Effort 1:

  var Client Script Manager = this.Page.ClientScript; If (! Kliantskriptmnagrkiscliantskriptinkluderegistred (Thiskgettype (), "Bingmpkantrol")) {Kliantskriptmnagrkregistrcliantskriptinklude (Thiskgettype (), "Bingmpkantrol", "Https://akankdevkvirtutlearthknet/mpkantrol/mpkantrol. ? Ashx v = 6.2 & amp; s = 1 "); }  

Try 2:

  HtmlGenericControl = include new HtmlGenericControl ( "script"); Include. Features. Add ("Type", "Text / JavaScript"); Include.Attributes.Add ("src", "https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1"); This.Page.Header.Controls.Add (included);  

Any ideas?

desired script tags:

& Lt; Script type = "text / javascript" src
= "https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v= 6.2 & amp; s = 1">
& lt; / Script>

In fact, not really, your desired script tag is:

  & lt; Script type = "text / javascript" src = "https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx? V = 6.2 & amp; s = 1" & gt; & Lt; / Script & gt;   

You do want & amp; & amp; Amp; What should be encoded as ? Because HTML standard say for example, XHTML 1.0, see part of the standard:

that document to make it compatible with historical HTML user agents and XML-based user agents, a document Empresand used in can be considered as verbal characters, they should be expressed as an entity reference (such as "" & amp; amp; "). For example, when href element a takes the parameters which refers to the CGI script element's value, then it http://my.site Should be expressed in the form. ? Dom / cgi-bin / myscript.pl class = guest & amp; Amp; Name = user rather than as http: //my.site.dom/cgi-bin/myscript.pl class = guest & amp; ; Name = user .


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -