Je possède ce code:Comment ajouter correctement un script à un contrôle?
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)
Cela génère la chose suivante:
<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>
Le problème est qu'il est HTML codé. Ma question est: comment s'assurer que le script ne sera pas encodé en HTML?
Utilisez RegisterClientScriptBlock. https://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerclientscriptblock(v=vs.110).aspx – Bert
Je vais bientôt tester cela. Pouvez-vous expliquer pourquoi le résultat du code affiché dans la question est codé en HTML? InnerText encode le texte. –
InnerHtml devrait lui permettre de passer à travers non codé. – Bert