HTML code show error on RadComboBox

4 posts, 0 answers
  1. Sushobhit
    Sushobhit avatar
    26 posts
    Member since:
    Apr 2011

    Posted 14 Sep 2012 Link to this post

    Hi all

     I have a  RadComboBox in asp.net and i have used  AllowCustomText="true" . so that way if user does not want to select the pre enter value he/she can enter his own value in radcombo box . but when a user can enter any element such like <b>,<br> mean any html tag and press enter button for submitting data it show error . i have create a java script code that removed <> before any text on blur event and it working fine to me but when i click to save the document it show error page . How can i solve this problem ?



    Thanks all 

    Sushobhit Raman
  2. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 17 Sep 2012 Link to this post

    Hi Sushobhit,

    The reason you have faced such an exception is that ASP.NET prevents from processing unencoded HTML content submitted to the server. Here you could find a help article, where you could observe how to disable this restriction and eventually apply your own custom validation.

    All the best,
    Nencho
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sushobhit
    Sushobhit avatar
    26 posts
    Member since:
    Apr 2011

    Posted 18 Sep 2012 Link to this post

    Hi Nencho
     
    Thanks for your suggestion but i need to that when user enter the nay HTML tag in the the code can remover HTML <> sigh. for example suppose user can enter <HTML>,<BR>,<a> etc when user can submit it then  <>  symbol  can remove only text can save 


    Thanks in advance
    Sushobhit Raman 

  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Sep 2012 Link to this post

    Hi Sushobhith,

    Try setting the following in web.config to allow html content in input.

    web.config 
    <system.web >
        <httpRuntime requestValidationMode="2.0" />
    </system.web >

    And you can remove html tags in javascript as follows.

    JS:
    <script type="text/javascript">
    function OnClientSelectedIndexChanging(sender, args)
    {
       var text = sender.get_text();
       text = text.replace(/</g, "");
       text = text.replace(/>/g, "");
       sender.set_text(text);
       sender.set_value(text);
    }
    </script>

    Hope this helps.

    Thanks,
    Princy.
Back to Top