Thursday, March 22, 2012

Server.HTMLEncode

Hey guys, im kinda struggling on this issue. I have a form that uses an html editor. My validation is set to true bc i have email, phone, and required field validations. What my task is is trying to convert the input captured in my textbox area(html editor) and convert it bc i need to keep the html code. heres my code. any help would be great. i've tried all kinds of ways to server.htmlencode it...thx

Sub Page_Load( s As Object, e As EventArgs )
If not Page.IsPostback then
'If Page.IsValid then
ThanksPnl.visible = False
FormPnl.Visible = True

TxtContent2.Text = Server.HtmlEncode(TxtContent.Text)

'End If
End If
End Sub

<tr>
<td valign="top" width="130px">Comments/Request:</td>
<td valign="top" align="left">
<asp:textbox ID="TxtContent" CausesValidation="False" width="300px" HtmlEncode="False" TextMode="Multiline" rows="10" runat="server" />
<asp:label ID="TxtContent2" CausesValidation="False" width="300px" HtmlEncode="False" TextMode="Multiline" rows="10" runat="server" />

<script language="JavaScript">
generate_wysiwyg('TxtContent');
</script></td>
</tr>

Confused

Do you want the lable "TxtContents2" to display the encoded contents of textbox? If so, I hope this one works for you

Sub Page_Load( s As Object, e As EventArgs )
If Page.IsPostback then
'If Page.IsValid then
ThanksPnl.visible = False
FormPnl.Visible = True

TxtContent2.Text = Server.HtmlEncode(TxtContent.Text)

'End If
End If
End Sub

<tr>
<td valign="top" width="130px">Comments/Request:</td>
<td valign="top" align="left">
<asp:textbox ID="TxtContent" CausesValidation="False" width="300px" HtmlEncode="False" TextMode="Multiline" rows="10" runat="server" />
<asp:label ID="TxtContent2" CausesValidation="False" width="300px" HtmlEncode="False" TextMode="Multiline" rows="10" runat="server" />

<script language="JavaScript">
generate_wysiwyg('TxtContent');
</script></td>
</tr>

0 comments:

Post a Comment