RadInputManager adding additional class attribute

2 posts, 0 answers
  1. David
    David avatar
    4 posts
    Member since:
    Jan 2012

    Posted 01 Feb 2012 Link to this post

    When I use the RadInputManager on a control declared as:

                <asp:TextBox ID="cname2" runat="Server" class="MyClass" Width="250px"></asp:TextBox>

    I get the following :

                <input name="cname2" type="text" id="cname2" class="RadInputMgr RadInputMgr_Office2010Blue RadInput_Enabled_Office2010Blue" class="MyClass" onmouseover="javascript:$radIE.mouseOver(event);" onmouseout="javascript:$radIE.mouseOut(event);" onkeypress="javascript:$radIE.keyPress(event);" onblur="javascript:$radIE.blur(event);" onfocus="javascript:$radIE.focus(event);" onkeyup="javascript:$radIE.keyUp(event);" style="width:250px;" />

    instead of

                <input name="cname2" type="text" id="cname2" class="RadInputMgr RadInputMgr_Office2010Blue RadInput_Enabled_Office2010Blue MyClass"  onmouseover="javascript:$radIE.mouseOver(event);" onmouseout="javascript:$radIE.mouseOut(event);" onkeypress="javascript:$radIE.keyPress(event);" onblur="javascript:$radIE.blur(event);" onfocus="javascript:$radIE.focus(event);" onkeyup="javascript:$radIE.keyUp(event);" style="width:250px;" />

    Having two class attributes in the html is causing problems with JQuery code like $(this).attr('class') since only the first class attribute is returned.

    Is there a way to get the RadInputManager to concatenate the class attributes instead of creating a new class attribute on the element?
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 06 Feb 2012 Link to this post

    Hi David,

    We did research on this topic, but we could not change the current behavior of the RadInputManager.
    Since the manager creates only one RadInputComponent for each TextBoxSetting, applying different styles is not possible.
    Persisting the original class for each Input would mean to create an object for each one, and this is against the idea of the InputManager, which is used to apply the same settings for all inputs for given setting. Storing different settings would cause lot of performance penalty what we wont to avoid. On the other hand storing all settings inside the RadInputComponent will cause problem during partial updates when you update only some of the TextBoxes. The this case the InputComponent will have old values after the update which would be not suitable for general usage.

    The manager overrides the CssClass property of the asp:TextBox, so to apply it's classes during the rendering properly, and to matches with the classes that are applied dynamically ClientSide.

    As a workaround you could create different TextBoxSettings for your inputs, if you have to group them in several groups. Or if you need to recognize each of them separately, it would be best to select them by ID instead of class.

    All the best,
    Vasil
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top