I have an issue with setting text to the combobox. If I set any text with "<,>" characters while submitting I am getting validation errors. I am adding the code so that you can reproduce. I cannot turn off validaterequest from the page.
HTML Code
C# Code
Attaching the result that I am getting.
HTML Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ValidateRequest="true" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
script
>
var RadFausTree = "";
function SFAUS() {
val = "<
ALL
>/<
ALL
>/<
ALL
>";
combo = $find(RadFausTree);
combo.trackChanges();
var escapedText = htmlEscape(val);
//esc = val;
//alert(escapedText);
combo.set_text(escapedText);
combo.set_value("");
cancelDropDownClosing = false;
combo.commitChanges();
combo.hideDropDown();
}
function htmlEscape(str) {
return String(str)
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</
g
, '<')
.replace(/>/g, '>');
}
</
script
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
runat
=
"server"
></
asp:ScriptManager
>
<
div
>
<
telerik:RadComboBox
ID
=
"RadFausTree"
Width
=
"100%"
Height
=
"300px"
AllowCustomText
=
"true"
EmptyMessage
=
"Select The Faus"
runat
=
"server"
/>
<
input
type
=
"button"
value
=
"Set Text"
onclick
=
"SFAUS()"
/>
<
asp:Button
runat
=
"server"
ID
=
"btnSubmit"
Text
=
"Submit"
OnClick
=
"btnSubmit_Click"
/>
</
div
>
</
form
>
</
body
>
</
html
>
C# Code
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
_Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
RegisterStartupScript (
"strKey"
,
"<script>RadFausTree='"
+RadFausTree.ClientID+
"';</script>"
);
}
protected
void
btnSubmit_Click (
object
sender, EventArgs e)
{
}
}
Attaching the result that I am getting.