Click to See Complete Forum and Search --> : label does not exist


Diedtje
03-23-2006, 03:51 AM
I have placed a label in my aspx page. When I trie to access it in my cs, Visual studio will recognize the control. So I can access the Text property. When I trie to build I get the following error:

The name lblHtmlRechts does not exist in the current context.
When i still run the project the label will appear, and the text will change. But why wont it build (and publish).

I tried to add protected Label lblHtmlRechts, but then it will just say that the label already exists, and trying the FindControl wont work either. Does anyone know the answer? It would help a lot, because I need this label to render HTML in my database.

Thank you

handshakeit
03-24-2006, 01:18 AM
Give some code Where you have used text property
without code it is difficult to answer the question

Thanks
Abhi
www.handshakeit.com

Diedtje
03-24-2006, 02:13 AM
here is the code. But I don't see a problem here. The codes recognizes the labels, but just gives the following error when building. running works fine

Error 1 The name 'lblHtmlLinks' does not exist in the current

ASPX:
---------

<asp:Table runat="server" width="750" BackColor="White" ID="tblLabels" HorizontalAlign="center" BorderStyle="None" BorderWidth="0" CellSpacing="0" CellPadding="0">
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server" ID="lblHtmlLinks" Width="374"></asp:Label>
</asp:TableCell>
<asp:TableCell Width="2" BackColor="Aqua"></asp:TableCell>
<asp:TableCell>
<asp:Label runat="server" ID="lblHtmlRechts" Width="374"></asp:Label>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="3">
<asp:HiddenField runat="server" ID="hdnClassId" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>


CS:
---------
SqlConnection myCon5 = new SqlConnection(ConfigurationManager.AppSettings["sqlConnectionString"]);
SqlCommand commandIP5 = new SqlCommand();
string SQLLog5 = "SELECT table_html FROM tbHtmlTable WHERE table_class_id = " + CLID + " AND table_position_id = 1";
commandIP5.Connection = myCon5;
commandIP5.CommandText = SQLLog5;
myCon5.Open();
SqlDataReader readerIP5 = commandIP5.ExecuteReader();
while (readerIP5.Read())
{
lblHtmlLinks.Text = readerIP["table_html"].ToString();
}
readerIP5.Close();
myCon5.Close();

sirpelidor
03-24-2006, 03:52 PM
is your problem similiar to this?

http://weblogs.asp.net/jmandia/archive/2006/01/05/434575.aspx

Kreeben
04-07-2006, 07:36 AM
I had the same problem. The page would run fine but would not build/publish. I then realized I had made a copy of the aspx page before doing some refactoring so I had two aspx pages referring to the same codebehind file. Upon deleting the copy the project would build.