如何在邮箱上固定具有较长数据的texbox的宽度? [英] How to fix width of texbox ,which have lengthy data,upon postbox ?

查看:84
本文介绍了如何在邮箱上固定具有较长数据的texbox的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,EB,

我有一个asp.net页面,其中每个控件的宽度都以%"形式显示.
有一个文本框,该文本框必须为单行文本.如果用户提供了一些冗长的数据,则在回发时,此数据将扩大文本框的控件范围.在编码时,其宽度在aspx页中以%"形式固定.

请让我知道如何保持文本框和表格的宽度固定吗?


问候,
Nilesh

Hi EB,

I have an asp.net page, where every control has width in ''%'' form.
There is one text box, which need to be single line text; if an user provide some lengthy data, upon postback, this data will widens textbox control. At coding time its width is fixed in ''%'' form in aspx page.

Please let me know how to keep width of textbox and form fixed?


Regards,
Nilesh

推荐答案

由于控件的宽度为%,因此会增加宽度.您需要使用条件表达式来设置宽度.在直到一定长度(例如300px)使用%的位置之后,始终使用300px的固定宽度.

更新:
在这里! [
Since the control width is in %, it increases the width. You need to use conditional expression to set the width. Where till a certain length like 300px use % and after that always a fixed width of 300px.

UPDATE:
Here is it![^]


在标签内使用带有width属性的style参数.这是此页面中的一个示例;

<textarea class="RateComment" rows="5" cols="60" style="width:285px;float:right">

更新:他正在使用文本框(而不是文本区域),宽度为%.将其固定为285将始终具有此宽度.看起来他需要避免基于输入到文本框中的长文本(其宽度以%设置)的方式来扩展页面,以使其在加载时占据所有可用空间. (当texbox中的文本长度驱动宽度而不是页面可用空间时,问题就会出现)
[Update2:我知道,其目的是展示样式元素的可用性,仅此而已.干杯,戴维.]
Use the style parameter with a width property within the tag. Here is an example of one from within this very page;

<textarea class="RateComment" rows="5" cols="60" style="width:285px;float:right">

UPDATE: He is using a textbox(not a textarea) and has % as width. Fixing it to 285 would always have this width. It looks like he needs to avoid widening of the page based on long text entered into the textbox whose width is set in % such that it occupies all the available space while loading. (Issue crops up when length of text inside the texbox drives the width and not the page avaialble space)
[Update2: I know, the intent was to show the availability of the style element, nothing else. Cheers, Davie.]


您可以使用max-width属性
在CSS文件中编写如下内容:
You may use max-width property
Write something like this in your CSS file:
.textbox1
{
  max-width: 300px;
  width: 100% !important
}



其中,textbox1是文本框的ID.
您可以用代码中指定的内容替换100%.

它适用于IE6 +和Mozilla 3.5+浏览器.尚未检查以前的版本.
检查一下,让我知道这是否是您想要的. :thumbsup:

干杯!
安库尔



where, textbox1 is the id of the textbox.
you can replace 100% with whatever you have specified in your code.

It works on IE6+ and Mozilla 3.5+ browsers. Have not checked for previous versions.
Check it out and let me know if this it what you wanted. :thumbsup:

Cheers!
Ankur


这篇关于如何在邮箱上固定具有较长数据的texbox的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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