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

RadTextBox EnabledStyle-HorizontalAlign="Right" on postback

3 Answers 519 Views
Input
This is a migrated thread and some comments may be shown as answers.
Sean Severson
Top achievements
Rank 1
Sean Severson asked on 04 Feb 2013, 06:57 PM

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

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Feb 2013, 07:28 AM
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.
0
Sean Severson
Top achievements
Rank 1
answered on 08 Feb 2013, 06:38 PM
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
0
Angel Petrov
Telerik team
answered on 13 Feb 2013, 02:20 PM
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.
Tags
Input
Asked by
Sean Severson
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Sean Severson
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or