I am using Tinymce editor for formatting articles in my ASP.NET page.
here is my code:-
<asp:TextBox runat="server" ID="textarea" Height="70px"
Width="324px" TextMode="MultiLine"></asp:TextBox><br />
<asp:Button ID="submit" runat="server" Text="Button"
OnClientClick="encodeMyHtml()" onclick="submit_Click" CausesValidation="False"/>
</div>
and this is what i have find on the web for encoding html here and tried to use it.
function encodeMyHtml() {
var htmlToEncode = document.getElementById("textarea").value;
// save content after encoding
alert(htmlToEncode);
var encodedHtml = escape(htmlToEncode);
alert(encodedHtml);
// Later when displaying it back, decode it.
var ohtml = unescape(encodedHtml);
alert(ohtml);
}
and this also
function encodeMyHtml() {
var htmlText = document.getElementById('textarea').value;
htmlText = htmlText.replace(/\</g, "<");
//alert("hello2");
htmlText = htmlText.replace(/\>/g, ">");
alert(htmlText);
}
but it's not working for me and it doesn't even display htmlToEncode value in alert() function. Everytime I click submit button, it display the following error
A potentially dangerous Request.Form value was detected from the client and etc..
Please help to figure out the Problem. I want to encode the HTML content and then store it into the database and then to retrieve it on another page.