Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why in aspx.cs page labal id is not exist..and "value " is also

What I have tried:

lblID.innertext=...
txtname.value="";
error in lblid and value
Posted
Updated 1-Jul-16 23:49pm
Comments
JayantaChatterjee 2-Jul-16 5:32am    
provide designer code, and Error details...

1 solution

Make sure that the label is having runat="server" attribute.
ASP.NET
<asp:label id="lblID" runat="server"></asp:label>


Inorder to Get/Set the value from Label Control or TextBox , use Text Property in aspx.cs
C#
lblID.Text = "some value";

C#
txtname.Text = "Some Name";


.value and .innerText works only on Javascript or you shall use Attributes[^] to set the value in c#
 
Share this answer
 
v2
Comments
Member 12556026 2-Jul-16 6:04am    
I am sure label have runat="server" attribut..
Karthik_Mahalingam 2-Jul-16 6:43am    
post your aspx code.
Member 12556026 2-Jul-16 6:57am    

Employee Request


<label id="lblerror" style="color: red" runat="server" ></label>
<div class="tab-content clearfix">
<div class="tab-pane active" id="1b">
<div class="row">
<div class="col-md-12">
<div id="page-wrap">

<table class="nav-justified">
<tr>
<td class="auto-style3">
<asp:Label ID="lblIDEmp" runat="server" Text="Employee ID">
</td>
<td class="auto-style9">
<asp:TextBox ID="txtIDEmp" runat="server">
</td>
<td class="auto-style11">
<asp:Label ID="lblIDSubCat" runat="server" Text="Category">
</td>
<td class="auto-style3">
<asp:DropDownList ID="ddlSubCat" runat="server">

</td>
<td class="auto-style12"> </td>
<td class="auto-style10"> </td>
</tr>
<tr>
<td class="auto-style5" rowspan="2">
<asp:Label ID="lblDescription" runat="server" Text="Description">
</td>
<td class="auto-style7" colspan="4" rowspan="2">
<asp:TextBox ID="txtDescription" runat="server" Height="92px" Width="473px">
</td>
<td class="auto-style10"></td>
</tr>
Karthik_Mahalingam 2-Jul-16 7:01am    
Please add closing tag to all controls
Member 12556026 2-Jul-16 7:05am    
sir there is already close..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900