开发者

TextBox Auto Expandable in ASP.NET

开发者 https://www.devze.com 2023-02-28 17:56 出处:网络
I have a TextBox like this; <asp:TextBox id=\"TextBox1\" TextMode=\"SingleLine\" runat=\"server\" />

I have a TextBox like this;

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

Is there any w开发者_运维知识库ay 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?


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.


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)%>"


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

Width='<%# (Eval("DataSourceField").ToString().Length * 8)%>'


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...........

0

精彩评论

暂无评论...
验证码 换一张
取 消