Question

I'm adding a script reference to a page header using a HtmlGenericControl. The problem is that it encodes the src parameters. So "&mkt=fr-FR" turns out as "&mkt=fr-FR" and doesn't get the correct script.

  var scriptTag = new HtmlGenericControl("script");
  scriptTag.Attributes.Add("type", "text/javascript");
  scriptTag.Attributes.Add("src", scriptUrl);

Update

Here is the url

http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=fr-FR

Était-ce utile?

La solution

Did you try Literal Control - Mode Property ?

<asp:Literal ID="Literal1" Mode="Encode" Text="<script type='text/javascript' 
     language='javascript' src='Scripts/jquery-1.4.1.min.js'></script>"
     runat="server">
</asp:Literal>

Output

<script type='text/javascript' language='javascript' 
                                      src='Scripts/jquery-1.4.1.min.js'></script>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top