Reputation: 117
My .aspx
looks like the following:
<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 File looks like:
if (results.Read())
{
labeluniversityid.value = results["TEXT_CONTENT"].ToString();
}
Exactly what am trying do is am getting the data from the database and displaying it in the valueIntroduction
div. That is workiing fine. Now i added a text box with readonly
mode. So that in my page if I press EDIT
button, the value could be edited.
Upvotes: 2
Views: 147
Reputation:
Use a TexBox component:
<asp:TextBox ID="labeluniversityid" runat="server" CssClass="yourcssclass"></asp:TextBox>
As for the styling:
.yourcssclass
{
color:#7D110C;
border:0;
background-color:#C0D5F2;
width:100%
}
Then, in your code behind you can easily use it like this:
labeluniversityid.Text = results["TEXT_CONTENT"].ToString();
Keep in mind that ASP.NET Controls are translated into common HTML tags, so you can wrap it and style it as you would with any other normal input of type text.
Also: type="text"
is not valid for div
Upvotes: 4
Reputation: 3570
You need to add -
runat="server"
to your input field
Or, even better, use an
<asp:textBox ..>
Upvotes: 0
Reputation: 149108
Try putting runat="server"
attribute in <input id="labeluniversityid">
tag.
Or use a <asp:TextBox>
control as areks suggests.
Upvotes: 1