Showing posts with label align. Show all posts
Showing posts with label align. Show all posts

Saturday, March 31, 2012

text box cursor position on entry

Hi I want the cursor to align left when someone clicks in textbox.

textbox has maxlength of 7 when user clicks in text box

the cursor is at position 2 so they cant enter all 7 digits of number

without clicking home and reentering number.

It sounds to me like the textbox has some default text in it already. Otherwise, it would be at the left when they click in. Post your code so we can take a look.
As, suggested please check the Text property. By default when you click inside the TextBox is should align to the left at position "0".

add this in page_load...

sub page_load(byval sender as object, byval e as system.eventargs) handles page.load

txt1.text=""

end sub

cheers

moredotnet


thanks for the replies, I have put txtbox.text="" in page load will see what happens.

please use me.load instead of page.load

cheers

moredotnet


How I CAn Change the Cursor Color or Size InHTML TextBox

Thanks


Hi,

call a java script function onfocus, then set the value of text box to null and then call focus function on that control.

hope this would solve your problem


Unfortunately this not solve my problrm

When textbox.value=null ;

the textbox value be "null"


I wanna to write a dataSet as XML File

I use dataset.WriteXML("Filename"); Method

But if ther are an empty cell it will not Writen

Pls. Help Me;


Hi ,

I couldn't get you complete requirement. Can you try like this.

First check whether your data set contain rows are not . If it contains then write to xml file using

ds.WriteXML("filename.xml")

Thursday, March 22, 2012

TextAlignment

How to align the text in textbox to the right. The default is left aligned.

Thanx

You can do that in the Style attribute (style="text-align: right;") , for example:

<asp:TextBoxID="TextBox1"runat="server"Text="test"style="text-align: right;" />

Or specify text-align:right; in a CSS class and use that cssClass on you Textbox

Tuesday, March 13, 2012

TextBox & label Bug

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

TextBox align=right?

With .NET 2.0:
Is there a way to right align the text in a textbox?
The task is to edit numbers in a table-column, and it looks kind of silly
with the numbers left-aligned.

A label respond to formatting of the table cell, but text within the texbox
doesn't.

Bjorn"Bjorn Sagbakken" <bjo-sag@.online.nowrote in message
news:T8idnUbcV6IJ7OPbRVnzvAA@.telenor.com...

Quote:

Originally Posted by

Is there a way to right align the text in a textbox?


<asp:TextBox ID="MyTextBox" runat="server" style="text-align:right;" />

--
http://www.markrae.net
"Mark Rae" <mark@.markNOSPAMrae.netwrote in message
news:O6k2GSmtHHA.3556@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

"Bjorn Sagbakken" <bjo-sag@.online.nowrote in message
news:T8idnUbcV6IJ7OPbRVnzvAA@.telenor.com...
>

Quote:

Originally Posted by

>Is there a way to right align the text in a textbox?


>
<asp:TextBox ID="MyTextBox" runat="server" style="text-align:right;" />


Thanks. That worked.
I was looking for something like that but didn't find anything browsing the
properties of the textbox, not even style.

Bjorn
Custom attributes defined on a WebControl's tag would be outputted as-is if
they are not recognized to match any typed property. Although, TextBox does
have Style property, inherited from WebControl and in this case iterating
through TextBox's Style property's keys would show text-align is there if
you specify it declaratively

<asp:TextBox ID="TextBox1" runat="server" style="text-align:right" />

foreach (string key in TextBox1.Style.Keys)
{
//Output the keys
}

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Bjorn Sagbakken" <bjo-sag@.online.nowrote in message
news:ufidnZCs671E6OPbRVnzvAA@.telenor.com...

Quote:

Originally Posted by

"Mark Rae" <mark@.markNOSPAMrae.netwrote in message
news:O6k2GSmtHHA.3556@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

>"Bjorn Sagbakken" <bjo-sag@.online.nowrote in message
>news:T8idnUbcV6IJ7OPbRVnzvAA@.telenor.com...
>>

Quote:

Originally Posted by

>>Is there a way to right align the text in a textbox?


>>
><asp:TextBox ID="MyTextBox" runat="server" style="text-align:right;" />


>
Thanks. That worked.
I was looking for something like that but didn't find anything browsing
the properties of the textbox, not even style.
>
Bjorn
>


"Teemu Keiski" <joteke@.aspalliance.comwrote in message
news:%23oE8d8ntHHA.5028@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Custom attributes defined on a WebControl's tag would be outputted as-is
if they are not recognized to match any typed property. Although, TextBox
does have Style property, inherited from WebControl and in this case
iterating through TextBox's Style property's keys would show text-align is
there if you specify it declaratively
>
<asp:TextBox ID="TextBox1" runat="server" style="text-align:right" />
>
foreach (string key in TextBox1.Style.Keys)
{
//Output the keys
}


Thanks. If I need to check out other keys, I will remember your tip.
I have some textboxes generated dynamically, and now I have applied a line
like this to each one of them:

ItemValue=New TextBox
ItemValue.Style("text-align")="right"

Bjorn

TextBox align=right?

With .NET 2.0:
Is there a way to right align the text in a textbox?
The task is to edit numbers in a table-column, and it looks kind of silly
with the numbers left-aligned.
A label respond to formatting of the table cell, but text within the texbox
doesn't.
Bjorn"Bjorn Sagbakken" <bjo-sag@.online.no> wrote in message
news:T8idnUbcV6IJ7OPbRVnzvAA@.telenor.com...

> Is there a way to right align the text in a textbox?
<asp:TextBox ID="MyTextBox" runat="server" style="text-align:right;" />
http://www.markrae.net
"Mark Rae" <mark@.markNOSPAMrae.net> wrote in message
news:O6k2GSmtHHA.3556@.TK2MSFTNGP05.phx.gbl...
> "Bjorn Sagbakken" <bjo-sag@.online.no> wrote in message
> news:T8idnUbcV6IJ7OPbRVnzvAA@.telenor.com...
>
> <asp:TextBox ID="MyTextBox" runat="server" style="text-align:right;" />
Thanks. That worked.
I was looking for something like that but didn't find anything browsing the
properties of the textbox, not even style.
Bjorn
Custom attributes defined on a WebControl's tag would be outputted as-is if
they are not recognized to match any typed property. Although, TextBox does
have Style property, inherited from WebControl and in this case iterating
through TextBox's Style property's keys would show text-align is there if
you specify it declaratively
<asp:TextBox ID="TextBox1" runat="server" style="text-align:right" />
foreach (string key in TextBox1.Style.Keys)
{
//Output the keys
}
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Bjorn Sagbakken" <bjo-sag@.online.no> wrote in message
news:ufidnZCs671E6OPbRVnzvAA@.telenor.com...
> "Mark Rae" <mark@.markNOSPAMrae.net> wrote in message
> news:O6k2GSmtHHA.3556@.TK2MSFTNGP05.phx.gbl...
> Thanks. That worked.
> I was looking for something like that but didn't find anything browsing
> the properties of the textbox, not even style.
> Bjorn
>
"Teemu Keiski" <joteke@.aspalliance.com> wrote in message
news:%23oE8d8ntHHA.5028@.TK2MSFTNGP02.phx.gbl...
> Custom attributes defined on a WebControl's tag would be outputted as-is
> if they are not recognized to match any typed property. Although, TextBox
> does have Style property, inherited from WebControl and in this case
> iterating through TextBox's Style property's keys would show text-align is
> there if you specify it declaratively
> <asp:TextBox ID="TextBox1" runat="server" style="text-align:right" />
> foreach (string key in TextBox1.Style.Keys)
> {
> //Output the keys
> }
Thanks. If I need to check out other keys, I will remember your tip.
I have some textboxes generated dynamically, and now I have applied a line
like this to each one of them:
ItemValue=New TextBox
ItemValue.Style("text-align")="right"
Bjorn