I am not able to align the numbers displayed in a textbox or a label to right side.
It is terrible problem and spent 2 hours in resolving the problem
Instead of displaying Values in the textbox or label i directly displayed in the table with right align.
Now it was working properly but every time the post back happens the values get empty
Please help to solve the problem. It urgent.
Hi,
have you tried just doing it like this
<asp:TextBox ID="TextBox1" runat="server" Text="text in TextBox"style="text-align:right" Width="200" /><br />
<asp:Label ID="Label1" runat="server" Text="text in Label"style="text-align:right" Width="200" />
Should work fine. Can you clarify what you mean by values getting empty after postback? How have you declared the controls and where do you assign the Text?
I did not get this idea.
Thanks.
I created some variables in the code file and i called this variables using <%= txtname %>
the values are getting empty when the postback happens, i have declared the variables
below the class file ?
What should i do to retain the values ?
2. I want to format the numbers like ##,##,##,###.00 ?. I have given it but the numbers
are not getting formatted in the textbox .
Wow, it's amazing how people with no clue cry out "bug in the system!" so easily
i was of thinking of windows forms where it is easy to specify the location , size & alignment
If the same property would have for webforms it would be easier for the developer.
Further , It would be great full how to do the number formatting of a text box according
to the indian style like 0:##,##,##,###.00.
Ganesh@.Nilgris:
I did not get this idea.
Thanks.
I created some variables in the code file and i called this variables using <%= txtname %>
the values are getting empty when the postback happens, i have declared the variables
below the class file ?
What should i do to retain the values ?
Standard variables created on class should use ViewState in order to preserve their state over postbacks. Reason is simple. Page class and controls are recreated for each request (also postback) so they are initialized to defaults.
Instead of using say
private int SampleInteger = 0;
Use a property
protected int SampleIntegerProperty
{
get
{
int retVal = 0;
object obj = ViewState["SampleIntegerProperty"];
if (obj != null)
{
retVal = (int)obj;
}
return retVal;
}
set
{
ViewState["SampleIntegerProperty"] = value;
}
}
Ganesh@.Nilgris:
2. I want to format the numbers like ##,##,##,###.00 ?. I have given it but the numbers
are not getting formatted in the textbox .
You can use String.Format.http://msdn2.microsoft.com/en-us/library/b1csw23d.aspx
I require a urgent solution for formatting the number , but the hyperlink is not giving a rigid answer.
Please help
Ganesh@.nilgris
0 comments:
Post a Comment