[英]How to get javascript/html Code as it is from a textbox
我想實現將adsense代碼存儲到sql數據庫的功能。 為此,我在文本框中使用了ajax:HtmlEditorExtender
。 現在我輸入此代碼
<script type="text/javascript"><!-- google_ad_client = "ca-pub-*****"; /* 728x90, created 6/12/02 */ google_ad_slot = "****"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead.googlesyndicaon.com/pead/show_ad.js"> </script>
現在的問題是當代碼插入數據庫時,上面的代碼轉換如下。
<pre><<span>script</span> <span>type</span>="<a>text/javascript</a>"><!--
<span></span>google_ad_client = "ca-pub-*****";
<span></span>/* 728x90, created 6/12/02 */
<span></span>google_ad_slot = "****";
<span></span>google_ad_width = 728;
<span></span>google_ad_height = 90;
<span></span>//-->
<span></span></<span>script</span>>
<span></span><<span>script</span> <span>type</span>="<a>text/javascript</a>"
<span></span><span>src</span>="<a href="view-source:http://pagead.googlesyndicaon.com/pead/show_ad.js">
http://pagead.googlesyndicaon.com/pead/show_ad.js</a>">
<span></span></<span>script</span>></pre>
請幫幫我:
提前致謝。
RE issue2:您可以使用普通的文本框並解碼字符串,或將其放回ajax:HtmlEditorExtender文本框,然后使用以下代碼(消毒程序可能已對所有標簽的開始和結束進行了編碼,等等。
Server.HtmlDecode(TextBox_Editor.Text)
回應您的評論:嘗試將解碼后的文本放入asp:label OnPreRender
編輯:嘗試使用HtmlAgilityPackSanitizerProvider,該最新程序包解決了圍繞消毒劑的某些“錯誤” ...閱讀此頁 ,Stephen Walters自己承認,默認消毒劑在剝離時過於激進。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.