RadTextBox EnabledStyle-HorizontalAlign="Right" on postback

4 posts, 0 answers
  1. Sean Severson
    Sean Severson avatar
    56 posts
    Member since:
    Aug 2009

    Posted 04 Feb 2013 Link to this post

    I have a web form with several RadTextBoxes.  One is shown here.

                    <telerik:RadNumericTextBox ID="tbHospitalPerVisit" runat="server" MaxLength="8" Width="115px"
                    ReadOnlyStyle-CssClass="ReadonlyDataEntry" EnabledStyle-HorizontalAlign="Right"
                    DisabledStyle-HorizontalAlign="Right">
                    <NumberFormat ZeroPattern="n"></NumberFormat>
                    <ReadOnlyStyle CssClass="ReadonlyDataEntry"></ReadOnlyStyle>
                </telerik:RadNumericTextBox>

    The EnabledStyle-HorizontalAlign property right aligns the text in the control.  When the page first loads I see the control formatted with the text right aligned.  On postback, however, the control is visible for a brief moment without the right alignment and then the text jumps to the right as the alignment is applied.

    My form has about 50 controls for collecting financial information.  Immagine seing data in all these controls jump from the left to the right when you save.

    How do I get the styling to be applied so that I do not see the control first displayed without the right alignment and then the alignment is applied?

    Thanks!

    Sean Severson

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

    Posted 05 Feb 2013 Link to this post

    Hi Sean Severson

    Try the following code snippet and let me know your concern.
    aspx:
    <telerik:RadNumericTextBox ID="TotalAccountBalanceTextbox" runat="server" CssClass="RightAligned">
    <EnabledStyle HorizontalAlign="Right" CssClass="RightAligned" />
    </telerik:RadNumericTextBox>
    CSS:
    <style type="text/css">
     .RightAligned
      {
        text-align: right;
      }
    </style>

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sean Severson
    Sean Severson avatar
    56 posts
    Member since:
    Aug 2009

    Posted 08 Feb 2013 Link to this post

    Princy,

    The style and property settings you provided keep the text right-aligned when I change the read only setting to false and the control is enabled.  If the readonly setting is true and a postback occurs, but there is no change in settings for the RadNumericTextBox, the text first appears left aligned and then jumps to right aligned.  I am setting the Enabled property to true in the code behind on the postback.

    Sean Severson
  5. Angel Petrov
    Admin
    Angel Petrov avatar
    1007 posts

    Posted 13 Feb 2013 Link to this post

    Hello Sean,

    Please try configuring the RadNumericTextBox like shown below:

    ASPX:
    <telerik:RadNumericTextBox ID="tbHospitalPerVisit" runat="server" MaxLength="8" Width="115px"
                    ReadOnlyStyle-CssClass="ReadonlyDataEntry" EnabledStyle-HorizontalAlign="Right"
                    DisabledStyle-HorizontalAlign="Right" >
                    <NumberFormat ZeroPattern="n"></NumberFormat>
                    <ReadOnlyStyle CssClass="ReadonlyDataEntry"></ReadOnlyStyle>
                    <DisabledStyle HorizontalAlign="Right" CssClass="RightAligned" />
                    <EnabledStyle HorizontalAlign="Right" CssClass="RightAligned" />
                    <FocusedStyle HorizontalAlign="Right" CssClass="RightAligned" />
                    <ReadOnlyStyle HorizontalAlign="Right" CssClass="RightAligned" />
                </telerik:RadNumericTextBox>

    CSS:
    .RightAligned
        {
            text-align: right;
        }

    Give this approach a try and let us know if it works out for you. Also I suggest that you take a look at this forum thread where the problem has already been discussed.

    All the best,
    Angel Petrov
    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.
Back to Top