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

8 posts, 0 answers
  1. Abhinav
    Abhinav avatar
    12 posts
    Member since:
    Aug 2011

    Posted 30 May 2012 Link to this post

    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.


  2. Abhinav
    Abhinav avatar
    12 posts
    Member since:
    Aug 2011

    Posted 04 Jun 2012 Link to this post

    Hi Team,

    Please give me your valuable support related to this issue.
    Waiting for your reply.
  3. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 04 Jun 2012 Link to this post

    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.
  4. Abhinav
    Abhinav avatar
    12 posts
    Member since:
    Aug 2011

    Posted 06 Jun 2012 Link to this post

    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
  5. Abhinav
    Abhinav avatar
    12 posts
    Member since:
    Aug 2011

    Posted 07 Jun 2012 Link to this post

    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. 
  6. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 08 Jun 2012 Link to this post

    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.
  7. Abhinav
    Abhinav avatar
    12 posts
    Member since:
    Aug 2011

    Posted 11 Jun 2012 Link to this post

    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.

  8. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 12 Jun 2012 Link to this post

    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.
Back to Top