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

RadInputManager adding additional class attribute

1 Answer 122 Views
Input
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 01 Feb 2012, 05:30 PM
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?

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 06 Feb 2012, 05:06 PM
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 >>
Tags
Input
Asked by
David
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or