Ich habe diesen Code:Wie füge ich ein Skript korrekt zu einem Steuerelement hinzu?
Dim script = New HtmlGenericControl("script")
script.Attributes.Add("type", "text/javascript")
script.InnerText = "var alohaInterval = setInterval(function() {if (typeof Aloha === ""undefined"") {return;} clearInterval(alohaInterval); Aloha.ready(function() {Aloha.jQuery("".editable-content"").aloha();})}, 100);"
htmlControl.Controls.Add(script)
Dies erzeugt die folgenden:
<script type="text/javascript">var alohaInterval = setInterval(function() {if (typeof Aloha === "undefined") {return;} clearInterval(alohaInterval); Aloha.ready(function() {Aloha.jQuery(".editable-content").aloha();})}, 100);</script>
Das Problem ist, dass es HTML-codiert ist. Meine Frage ist: Wie stelle ich sicher, dass das Skript nicht HTML-codiert ist?
Verwendung Registerclient. https://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerclientscriptblock(v=vs.110).aspx – Bert
Ich werde das bald testen. Kannst du erklären, warum das Ergebnis des in der Frage gezeigten Codes HTML-codiert ist? –
InnerText codiert den Text. InnerHtml sollte es ermöglichen, nicht codierte Daten zu übertragen. – Bert