【问题标题】:Textbox control is automatically increase width depending on text文本框控件根据文本自动增加宽度
【发布时间】:2016-08-04 11:26:45
【问题描述】:

文本框控件会根据asp.net数据库中的填充文本自动增加宽度

【问题讨论】:

  • 你给文本框指定宽度了吗??
  • 是的,我给了文本框宽度
  • 您可以发送您的代码吗??
  • 这是您遇到的问题还是您想要达到的结果?

标签: javascript jquery asp.net .net c#-4.0


【解决方案1】:

试试这个代码,

<html>
<head>
  <script type="text/javascript">
     function Increse(obj){
      if (!obj.s) obj.s=obj.size;
      obj.size=Math.max(obj.s,obj.value.length);
     }
  </script>
  </head>
  <body>
     <form>
       <input  type="text" size="5" style="font-family:Courier;" onkeyup="Increse(this);">
     </form>
  </body>
</html>

希望它会起作用。

【讨论】:

  • 值来自数据库。这里不知道为什么需要onkeyup函数
  • 我没有看到来自 db 的值。你可以做一件事,设置 AutoSize : false 然后将文本框扩展到最大文本值。
  • 如何设置 Autosize :false ?
  • txtMgrEmail.Text = dt.Rows[0]["branchemailid"].ToString();
猜你喜欢
  • 2011-01-24
  • 2012-07-11
  • 1970-01-01
  • 2017-05-17
  • 2019-12-01
  • 2014-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多