There are many questions with the same name as this one, but I have not found a solution.
MasterPage.master:
<div id="dateShow"> <asp:Label ID="lblDateShow" runat="server"></asp:Label> </div>
MasterPage.master.cs:
protected void Page_Load(object sender, EventArgs e) { lblDateShow.Text = DateTime.Now.ToShortDateString(); }
This happens during construction and shows me an error, but if I run without a building (before starting β no assembly), it will show me the date. This only happens on the main page with all the controls that I want to add, on other pages everything works fine. What could be the problem?
Error message:
Error 1 The name "lblDateShow" does not exist in the current context
Long mention:
Warning 2 The type "MasterPage" in "c: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET Files \ thegame \ 6da1e5d1 \ 9152b07 \ App_Web_tmu2ya5i.4.cs" conflicts with the imported type "MasterPage" in " c: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET files \ thegame \ 6da1e5d1 \ 9152b07 \ App_Web_masterpage.master.cdcab7d2.k9aa16y-.dll '. Using the type defined in' c: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET Files \ thegame \ 6da1e5d1 \ 9152b07 \ App_Web_tmu2ya5i.4.cs'. C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET Files \ thegame \ 6da1e5d1 \ 9152b07 \ App_Web_tmu2ya5i.4.cs
I tried to delete Temp files, did not help ..
UPD I solved this problem. I had another masterpage2.master, and it somehow dealt with all the problems. When I created a shortcut or other control, it was declared on the second main page, I do not know how this can be))
source share