2

I have a TextBox like this;

<asp:TextBox id="TextBox1" TextMode="SingleLine" runat="server" />

Is there any way makingAuto Expandable without Javascript or any other technology?

Can i do that just with ASP.NET ? (Some properties maybe)

OR what is the easiest way?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
  • "Auto Expandable" is auto re-size widht of 'TextBox'. When i write 5 letters 'TextBox.Widht' should be 50 px, for 10 letters should be 100px for example..! – Soner Gönül Apr 25 '11 at 07:20

4 Answers4

2

You can use ASP.NET AJAX ResizableControl Extender if you plan on using ajax control toolkit.(Which internally uses javascript I think), I'm not aware of any other non-javascript way.

Kamyar
  • 18,639
  • 9
  • 97
  • 171
  • But this isn't automaticly right? Yes it can provide re-size properties but users must changes size of control. Is there any automaticly way? – Soner Gönül Apr 25 '11 at 07:28
  • Not that I'm aware of. basically, every action in client-side is handled by javascript. That's the only language browsers understand. – Kamyar Apr 25 '11 at 11:16
1

You can use the dynamic server tag for setting the Width.

Width='<%# (Eval("DataSourceField").ToString().Length * 8)%>'
Bryan
  • 3,629
  • 2
  • 28
  • 27
1
protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        int i = TextBox1.Text.Length;
        int rowsize = (i / 10)+2;
        TextBox1.Rows = rowsize;
        TextBox1.Focus();
    }

Try This...........

Chetan Sanghani
  • 2,058
  • 2
  • 21
  • 36
1

You only can make it without javascript if you already know the content and you don't want the width to change dynamically while the user types. Something like Width="<%=(SourceString.Length * 10)%>"

ariel
  • 15,620
  • 12
  • 61
  • 73