简体   繁体   中英

TextBox Auto Expandable in ASP.NET

I have a TextBox like this;

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

Is there any way making Auto Expandable without Javascript or any other technology?

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

OR what is the easiest way?

如果计划使用ajax控件工具包,则可以使用ASP.NET AJAX ResizableControl Extender。(我认为内部使用的是javascript),但我不知道其他任何非javascript方式。

您可以使用动态服务器标签来设置宽度。

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM