This is a migrated thread and some comments may be shown as answers.

Combobox gives javascript error while adding HTML or XML tag in it.

7 Answers 159 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Abhinav
Top achievements
Rank 1
Abhinav asked on 31 May 2012, 04:26 AM
Hi Team,
I am facing one issue, While adding any HTML or XML tag in my telerik:RadComboBox 
 it is giving a javascript error as :
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
This error is only coming when I put < with some alphabets ex: "<aa","<a" or "<TEST>".
Even it is working proper when I put "aa>" or "<>".

I have followed the solution suggested as in thread:
http://www.telerik.com/community/forums/aspnet/combobox/combobox-crashes-opon-entering-html-tags.aspx 

As my error is coming on Client side so I have used htmlEncode method also as:
$('<div/>').text(value).html();
Still I am facing the same issue.
Please give suggestion to resolve this issue.


7 Answers, 1 is accepted

Sort by
0
Abhinav
Top achievements
Rank 1
answered on 04 Jun 2012, 01:14 PM
Hi Team,

Please give me your valuable support related to this issue.
Waiting for your reply.
0
Ivana
Telerik team
answered on 04 Jun 2012, 08:00 PM
Hi Abhinav,

Could you paste the troubled code here?

All the best,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Abhinav
Top achievements
Rank 1
answered on 06 Jun 2012, 10:17 AM
Hi Ivana,

I have created a Test Application for this issue.
But not able to attach the Zip file.
Let me know how to send it to you.

My mail Id is as: abhinav.naresh@trizetto.com
If possible please drop me a mail so that I can share the test application with you.
Waiting for your valuable reply.

Thanks in Advance.
Abhinav Naresh
0
Abhinav
Top achievements
Rank 1
answered on 07 Jun 2012, 08:55 AM
Hi Ivana, 
Please find my Code as below:

  1.  Default.aspx page:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="TestApplication._Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script language="javascript" type="text/javascript">
    function rboxValues_OnClientBlur(sender, eventArgs) {
        $('#hdnNewValueText').val(sender.get_text());
        var newValue = sender.get_text();
        sender.set_text(newValue);
        return true;
    }
</script>
        <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePageMethods="true" >
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </asp:ScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="rboxValues">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="lstValues"  />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="btnAddValue">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="lstValues"  LoadingPanelID="loadingPanel1"  />
                <telerik:AjaxUpdatedControl ControlID="rboxValues" />
            </UpdatedControls>
        </telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadComboBox ID="rboxValues" runat="server"
                OnClientBlur="rboxValues_OnClientBlur"
                AllowCustomText="true"
                AutoPostBack="true" Width="100%"
                EmptyMessage="Enter text....">
            </telerik:RadComboBox>
<asp:Button ID="btnAddValue" runat="server" OnClick="addToValueList" Text="Add" />
<br />
<telerik:RadListBox runat="Server" ID="lstValues" Height="300" Width="98%"
                AutoPostBack="true">
            </telerik:RadListBox>
</asp:Content>

2. Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
 
namespace TestApplication
{
    public partial class _Default : System.Web.UI.Page
    {
        OleDbConnection connection = new OleDbConnection();
 
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void addToValueList(object sender, EventArgs e)
        {
 
            try
            {
                var lstItem = new RadListBoxItem();
                lstItem.Value = rboxValues.Text.Trim();
                lstItem.Text = rboxValues.Text.Trim();
 
                lstValues.Items.Clear();
                lstValues.Items.Add(lstItem);
                rboxValues.Items.Clear();
                rboxValues.Text = string.Empty;
                rboxValues.EmptyMessage = "Enter text....";
            }
            catch (Exception ex)
            {
 
            }
 
        }
 
    }
}

Please provide your comment. 
0
Ivana
Telerik team
answered on 08 Jun 2012, 12:28 PM
Hello Abhinav,

I have tried to replicate the discrepancies using the code provided, but unfortunately to no avail. Here is how your scenario behaves at my end: http://screencast.com/t/tp1yRIky6PMZ. Am I missing something?

If the troubles continue, I encourage you to open a support ticket and send us a sample project in there so we will be able to investigate the very same scenario you experience problems with.

Greetings,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Abhinav
Top achievements
Rank 1
answered on 11 Jun 2012, 10:43 AM
Hi Ivana,

I have gone through the video as provided by you.
You are using 111, 222, 333 as the RadComboBoxItem.
If you use <TEST> as the RadComboBoxItem or add it in the RadComboBox from UI a javascript error occurs (as in attachment).

I have captured my screen also,Please go through below video link:
http://www.screencast.com/users/Abhinav.Naresh/folders/Telerik/media/a9e3f54f-39e2-4edb-bb28-cab1f24a7aac 

I have followed the solution suggested as in thread:
http://www.telerik.com/community/forums/aspnet/combobox/combobox-crashes-opon-entering-html-tags.aspx 

But still not got success.

0
Ivana
Telerik team
answered on 12 Jun 2012, 02:32 PM
Hello Abhinav,

I am sorry for misleading you in my last post.

It turned out that asp.net considers the text '<TEST>' as a potentially dangerous Request.Form value for an input for this value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. In order to overcome this behavior you need to set the requestValidationMode attribute in the httpRuntime configuration section to requestValidationMode="2.0"  as it is shown in the following example,
<system.web>
    <httpRuntime requestValidationMode="2.0" />
     ...
</system.web>
and then you need to disable request validation by setting validateRequest="false" in the Page directive, or in the <pages> configuration section of the web.config file of your application. You should keep in mind, however, that you need to explicitly check all inputs in your application in this case.

I hope this will help.

Greetings,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
Abhinav
Top achievements
Rank 1
Answers by
Abhinav
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or