I'm looking for to encode both the "< to < and > for > but not getting the right value for it, so I'm wondering if there is a way to encode the Html in the javaScript and call it at the control ID, I try something like
this in the JavaScript but it's not working, Does anyone know how to do it ? thanks..
string e =
"<script lang='javascript' />";
string e1 = HttpUtility.HtmlEncode(e);
string e2 = HttpUtility.HtmlAttributeEncode(e);
e1 = "<script lang='javascript' />"
e2 =
"<script lang='javascript' />"
<
asp:dropdownlist
id="TextBoxSiteUse" lang = "e"
runat="server"
>
If you are trying to call a javascript function when drop list value changed, then you can have this function written anywhere in the aspx within [code]<script>[/code] and [code]</script>[/code] block. Then you can embed a function call to drop down list like
below. For my example i am trying to call CheckChange as a function name.
[code]
<script language=javascript>
function CheckChange(dropdown)
{
// do something here
}
</script>
[/code]
And you need to attach the event handler like this.
[code]
[/code]
Remember to click on Mark as answer on the post that helped you
Marked as answer by Kevin Yu - MSFT on Sep 03, 2007 06:06 AM
function escapeHTML (str)
{
var div = document.createElement('div');
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
}
olaamigos
Member
45 Points
294 Posts
HttpUtility.HtmlEncode in javaScript?
Aug 28, 2007 05:02 PM|LINK
Hi there,
I'm looking for to encode both the "< to < and > for > but not getting the right value for it, so I'm wondering if there is a way to encode the Html in the javaScript and call it at the control ID, I try something like this in the JavaScript but it's not working, Does anyone know how to do it ? thanks..
string e = "<script lang='javascript' />";string e1 = HttpUtility.HtmlEncode(e);
string e2 = HttpUtility.HtmlAttributeEncode(e);
e1 = "<script lang='javascript' />"e2 =
"<script lang='javascript' />"<
asp:dropdownlist id="TextBoxSiteUse" lang = "e" runat="server" ><
asp:ListItem Value="Unit (<=4 )">Unit (<=4 )</asp:ListItem> <asp:ListItem Value="Unit (>=4 )">Unit (>=4 )</asp:ListItem>satishpk
Participant
758 Points
110 Posts
Re: HttpUtility.HtmlEncode in javaScript?
Aug 28, 2007 06:38 PM|LINK
[code] unescape("<script lang='javascript' />")
[/code]
will give you
[code] <script lang='javascript' />
[/code]
olaamigos
Member
45 Points
294 Posts
Re: HttpUtility.HtmlEncode in javaScript?
Aug 30, 2007 03:06 AM|LINK
Thanks Satishpk for replying
I try it but it's not working or even trigger the Dropdownlist to match with that values
<script lang='javascript'>
unescape("<script lang='javascript' />")
</script>
<asp:dropdownlist id="TxtSize" lang = " unescape" runat="server" >
satishpk
Participant
758 Points
110 Posts
Re: HttpUtility.HtmlEncode in javaScript?
Aug 30, 2007 05:00 AM|LINK
[code]
<script language=javascript>
function CheckChange(dropdown)
{
// do something here
}
</script>
[/code]
And you need to attach the event handler like this.
[code]
[/code]
BrunoLM
Member
5 Points
10 Posts
Re: HttpUtility.HtmlEncode in javaScript?
Sep 30, 2010 12:13 PM|LINK
Actually unescape isn't working for me.
I found this hack to encode html
function escapeHTML (str) { var div = document.createElement('div'); var text = document.createTextNode(str); div.appendChild(text); return div.innerHTML; }http://lunarmedia.com/blogs/lunarmedia_blog/archive/2006/10/23/120405.aspx