我的.aspx
如下所示:
<div id="valueIntroduction" type="text" class="labelarea" runat="server">
<input name="$labeluniversityid" type="text" id="labeluniversityid" style="color:#7D110C;border:0;background-color:#C0D5F2;width:100%" />
</div>
.cs文件看起来像:
if (results.Read())
{
labeluniversityid.value = results["TEXT_CONTENT"].ToString();
}
我正在尝试做的是从数据库中获取数据并将其显示在valueIntroduction
div中。那很好用。现在我添加了一个readonly
模式的文本框。因此,如果我按EDIT
按钮,则在我的页面中,可以编辑该值。
答案 0 :(得分:4)
使用TexBox组件:
<asp:TextBox ID="labeluniversityid" runat="server" CssClass="yourcssclass"></asp:TextBox>
至于造型:
.yourcssclass
{
color:#7D110C;
border:0;
background-color:#C0D5F2;
width:100%
}
然后,在您的代码中,您可以轻松地使用它:
labeluniversityid.Text = results["TEXT_CONTENT"].ToString();
请记住,ASP.NET控件已转换为常用的HTML标记,因此您可以像使用任何其他类型文本的常规输入一样对其进行包装和设置样式。
另外:type="text"
对div
答案 1 :(得分:1)
尝试将runat="server"
属性放入<input id="labeluniversityid">
标记。
或者使用<asp:TextBox>
控件作为 areks 建议。
答案 2 :(得分:0)
您需要添加 -
runat="server"
到您的输入字段
或者,更好的是,使用
<asp:textBox ..>