Note that there are some explanatory texts on larger screens.

plurals
  1. POAssign converted html to a serverside control
    text
    copied!<p>I'm using markdown and I've got some input such as <code>**test**</code> which makes the word test appear in bold <strong>test</strong> and I've converted it with html like so"</p> <pre><code> var converter1 = Markdown.getSanitizingConverter(); var editor1 = new Markdown.Editor(converter1); editor1.run(); var d = document.getElementById("wmd_input"); var html = converter1.makeHtml(d.value); alert(html); </code></pre> <p>And this alerts <code>&lt;b&gt;test&lt;/b&gt;</code> the issue is I need to take this value, namely <code>&lt;b&gt;test&lt;/b&gt;</code> and access this via server side code (asp.net). I tried assigning it to a variable like so:</p> <pre><code> document.getElementById("Label1").value = html; </code></pre> <p>But it doesn't seem to work, when I go to the code behind it shows <code>Label1</code> as being empty. Is this possible?</p> <h2>Edit</h2> <p>I tried to change it to a hidden field same issue:</p> <pre><code>&lt;script type="text/javascript"&gt; (function () { var converter1 = Markdown.getSanitizingConverter(); var editor1 = new Markdown.Editor(converter1); editor1.run(); var d = document.getElementById("wmd_input"); var html = converter1.makeHtml(d.value); alert(html); document.getElementById('&lt;%= h1.ClientID %&gt;').value = html; var h = document.getElementById('&lt;%= h1.ClientID %&gt;'); alert(h.value); })(); &lt;/script&gt; </code></pre> <p>The issue I have is I have an asp.net server side button that when clicked I try to do this:</p> <p><code>Label1.Text = h1.Value;</code></p> <p>That is to store the value from the hidden field to a label but this doesnt work. When I put a break point in it shows <code>h1</code> is empty <code>""</code>....So I'm not sure what event or how to do this so that when I make changes to my textarea <code>wmd_input</code> that i should be able to see these changes in my server side code...</p> <p>Here's my entire asp.net form:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;PageDown Demo Page&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="css/demo.css" /&gt; &lt;script type="text/javascript" src="js/Markdown.Converter.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/Markdown.Sanitizer.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/Markdown.Editor.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="myForm" runat="server"&gt; &lt;div class="wmd-panel"&gt; &lt;div id="wmd-button-bar"&gt;&lt;/div&gt; &lt;textarea cols="5" rows="5" id="wmd_input" class="wmd-input" runat="server"&gt;&lt;/textarea&gt; &lt;div id="wmd_preview" class="wmd-panel wmd-preview" runat="server"&gt;&lt;/div&gt; &lt;/div&gt; &lt;asp:button id="Button1" runat="server" Text="Set" onclick="Button1_Click"&gt;&lt;/asp:button&gt; &lt;asp:button id="Button2" runat="server" Text="Get" onclick="Button2_Click"&gt;&lt;/asp:button&gt;&lt;asp:label id="Label1" runat="server"&gt;Label&lt;/asp:label&gt; &lt;asp:HiddenField ID="h1" runat="server" EnableViewState="true" /&gt; &lt;script type="text/javascript"&gt; (function () { var converter1 = Markdown.getSanitizingConverter(); var editor1 = new Markdown.Editor(converter1); editor1.run(); var d = document.getElementById("wmd_input"); var html = converter1.makeHtml(d.value); alert(html); document.getElementById('&lt;%= h1.ClientID %&gt;').value = html; alert(document.getElementById('&lt;%= h1.ClientID %&gt;').value); })(); &lt;/script&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload