Reputation: 98760
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?
Upvotes: 2
Views: 7278
Reputation: 2111
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...........
Upvotes: 1
Reputation: 3667
You can use the dynamic server tag for setting the Width.
Width='<%# (Eval("DataSourceField").ToString().Length * 8)%>'
Upvotes: 1
Reputation: 16150
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)%>"
Upvotes: 1
Reputation: 18797
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.
Upvotes: 2