ASP.Net中文本框的锁定大小 [英] lock size of textbox in ASP.Net

查看:89
本文介绍了ASP.Net中文本框的锁定大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c#Asp.net的网站项目中的gridview中添加了多行文本框.我将从数据库检索文本到我的文本框.

我将texbox的宽度和高度设置为100%,并将其放在div中.但是,当我在浏览器中查看网站时,div不会填满并且它是可调整大小的.我还在.css文件中将div的高度和宽度设置为100%.

如何用文本框填充div并锁定文本框的大小?

I added a multiline textbox to gridview in my website project in c# Asp.net. I will retrieve text from database to my textbox.

I set the width and height of texbox to 100% and put it in a div. But when I view the site in browser doesnt fill the div and it is resizeable. I also set the height and width of div to 100% in my .css file.

How can I fill the div with textbox and lock the size of textbox?

推荐答案

在C#中:
<asp:textbox id="txtComments" runat="server" bordercolor="Gray" xmlns:asp="#unknown">
           BorderStyle="Solid" BorderWidth="1px" CausesValidation="true" Wrap="true"
           MaxLength="100"
           TextMode="MultiLine" 
           Width="350px"></asp:textbox>



在aspx.cs



in aspx.cs

public int MaxLength
   {
       get { return txtComments.MaxLength; }
       set { txtComments.MaxLength = value; }
   }
   public void wordCount()
   {
       txtCount.Text = txtComments.MaxLength.ToString();
       txtComments.Attributes.Add("onKeyUp", "javascript:document.getElementById('" + txtCount.ClientID + "').setAttribute('value', (" + txtComments.MaxLength + " - parseInt(document.getElementById('" + txtComments.ClientID + "').getAttribute('value').length)));");

   }


这篇关于ASP.Net中文本框的锁定大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆