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: 

  • No table is used when having buttons and/or labels, which results in quicker rendering.
  • Less HTML is rendered as a whole, which leads to less data transferred to the client.
  • The control can show readable text when the input is in password mode. This is useful for showing empty and error messages.
  • The ClientID of the control will be used for the <input> element in which the user types. So you will no longer need to add anything like “_text” when need to get it by ID.
  • Since the new rendering is not using any tables, the control is always held in a span. This allows for placing the control inside paragraphs for instance without breaking the XHTML validation.

How it works

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:

  1. The input element in which the user types and submits.
  2. Span element over the input that holds formatted and empty messages when needed.

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">
  1. When the page loads, the user will see “Please Enter Date” text over the input. In the same time value of the input is an empty string. This means that Validation value (the value that would be submitted, if the user makes a Postback) will be null;
  2. Then the user clicks on the input. Now we are going into the focus stage. The span gets hidden and the user sees empty input with a blinking caret inside.
  3. Since the user is not required to know what is the edit value he could type “10.22.2011” (without the quotes). The date is parsed and autocorrected depending on the DateFormat. So the Edit value gets “2011/10/22”. As the input is still in focus, the user will see this corrected value in the input, he could modify it further or decide that is correct one.
  4. The user clicks away (or tabs) to blur the textbox. So we are going to blur stage. As a result the Display value gets changed to “22 October 2011” according to the selected DisplayDateFormat. At the same time Validation value gets “2011-10-22-00-00-00” which can easy be validated regardless of the culture settings and preferred displaying format.
  5. If the user clicks again on the input and focus it, he will see back the Edit value “2011/10/22” and so on.

See the difference

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;">
      <label class="riLabel" for="rntb1_text" id="rntb1_Label">Text Box1</label>
    <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 class="riBtn">
      <a href="javascript:void(0)" id="rntb1_GoButton"><span>Button</span></a>
<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>
  <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.

Style easier

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.


About the Author

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.

Related Posts


Comments are disabled in preview mode.