As we are constantly trying to improve our controls, in Q3 2011 we are introducing new HTML rendering for Telerik’s ASP.NET AJAX Input control – single input rendering. First of all I should assure you that the old rendering is still available, so all your custom styles and complicated scenarios with RadInput will still work.
Let’s check some of the advantages of the single input rendering mode comes with:
To turn on the new rendering you just need to set the EnableSingleInputRendering property to true (the default value is false) for the RadInput controls on the page.
With the new rendering the two main HTML elements of the RadInput are:
The control has two main stages: focus and blur. When the control is in focus, the <span> element is not visible, this allows the user to see the text that he types. We call this text “Edit value”, since the user edits it. When the control is not in focus, the <span> element that holds formatted value (also called as “Display value”) is shown to the user. At the same time the value in the <input> could be corrected depending on the validation format and I will refer to this formatted value as “Validation value”.
Let me give an example with RadDateInput defined as follows:
<
telerik:RadDateInput
ID
=
"RadDateInput1"
runat
=
"server"
EnableSingleInputRendering
=
"true"
EmptyMessage
=
"Please Enter Date"
DateFormat
=
"yyyy/MM/dd"
DisplayDateFormat
=
"dd MMMM yyyy"
>
</
telerik:RadDateInput
>
Here is an example declaration of NumericTextBox using the old rendering:
<
telerik:RadNumericTextBox
runat
=
"server"
ShowButton
=
"true"
ID
=
"rntb1"
Label
=
"Text Box1"
></
telerik:RadNumericTextBox
>
Will render like:
<
div
id
=
"rntb1_wrapper"
class
=
"RadInput RadInput_Default"
style
=
"display: -moz-inline-stack; width: 125px; height: 20px;"
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
class
=
"riTable"
style
=
"border-width: 0; border-collapse: collapse; width: 125px;"
>
<
tr
>
<
td
>
<
label
class
=
"riLabel"
for
=
"rntb1_text"
id
=
"rntb1_Label"
>Text Box1</
label
>
</
td
>
<
td
class
=
"riCell"
style
=
"width: 100%; white-space: nowrap;"
>
<
input
type
=
"text"
id
=
"rntb1_text"
name
=
"rntb1_text"
class
=
"riTextBox riEnabled"
style
=
"width: 100%;"
/><
input
style
=
"visibility: hidden; float: right; margin: -18px 0 0 -1px; width: 1px; height: 1px; overflow: hidden; border: 0; padding: 0;"
id
=
"Text1"
class
=
"rdfd_"
value
=
""
type
=
"text"
title
=
""
/><
input
style
=
"visibility: hidden; float: right; margin: -18px 0 0 -1px; width: 1px; height: 1px; overflow: hidden; border: 0; padding: 0;"
id
=
"rntb1_Value"
class
=
"rdfd_"
name
=
"rntb1"
value
=
""
type
=
"text"
title
=
""
/>
</
td
>
<
td
class
=
"riBtn"
>
<
a
href
=
"javascript:void(0)"
id
=
"rntb1_GoButton"
><
span
>Button</
span
></
a
>
</
td
>
</
tr
>
</
table
>
<
input
id
=
"rntb1_ClientState"
name
=
"rntb1_ClientState"
type
=
"hidden"
/></
div
>
And the same input with EnableSingleInputRendering="true" will render like:
<
span
id
=
"rntb2_wrapper"
class
=
"riSingle riContButton RadInput RadInput_Default"
style
=
"width: 160px;"
>
<
label
class
=
"riLabel"
for
=
"rntb2"
id
=
"rntb2_Label"
style
=
"width: 64px;"
>Text Box2</
label
>
<
span
class
=
"riContentWrapper"
style
=
"width: 96px;"
><
span
class
=
"riDisplay"
id
=
"rntb2_display"
style
=
"display: none;"
></
span
>
<
input
id
=
"Text2"
name
=
"rntb2"
type
=
"text"
class
=
"riTextBox riEnabled"
/>
<
a
class
=
"riButton"
href
=
"javascript:void(0)"
id
=
"rntb2_GoButton"
><
span
>Button</
span
></
a
>
</
span
>
<
input
id
=
"rntb2_ClientState"
name
=
"rntb2_ClientState"
type
=
"hidden"
/></
span
>
As you can see above, the rendered HTML is almost twice shorter in the second sample. You could find a live comparison in our online demos here.
With the new rendering we are also trying to make Telerik’s ASP.NET AJAX Input control even easier to style than it was before. You will find information on what CSS classes are applied to the elements in our help resources.
I hope that you will like the improvement. Try it out and share your experience, all feedback is highly appreciated.
Iana Tsolova is Product Manager at Telerik’s DevTools division. She joined the company back in the beginning of 2008 as a Support Officer and has since occupied various positions at Telerik, including Senior Support Officer, Team Lead at one of the ASP.NET AJAX teams and Technical Support Director. Iana’s main interests are web development, reading articles related to geography, wild nature and latest renewable energy technologies.