Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys in my website asp.net c# project I have the following code

XML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PDTSuccess.aspx.cs" Inherits="FurSiteMs.PDT.PDTSuccess" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <b>Personalized 'Thank you' for customer:</b><br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

        <br /><br />

        <b>PDT Response</b><br />
        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>


and in c# file

C#
namespace FurSiteMs.PDT
{
    public partial class PDTSuccess : System.Web.UI.Page
    {


....

Label2.Text="hello";

but I receive an error message Label2 content does not exist to the current content.

I try to delete my designer.cs file but nothing... I try to remove it complete and also nothing..

what else i shoul try in order to solve the problem?


Thnx in advance for your help and your time!
Posted
Comments
Remove it, then Right Click on that file -> Convert to Web Application.
It will create the updated designer file for you. Try and let me know.
JasonTsoum77 1-Nov-13 9:42am    
Hi I don'y know if i'm doing something wrong but i can't find the option with right click on aspx file convert to web application . I'm using Visual studio 2012 so i thing there is the problem.
Any idea how can i do this in vs2012
Otherwise add the following code in Designer file manually.

/// <summary>
/// Label2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label2;
JasonTsoum77 1-Nov-13 15:45pm    
Hi Tradit I tried it but still nothing (in the designer.cs it already have it)
I delete it and I create it again but still nothing.
Can you show the .cs code where you exactly trying to access the Label?

After a lot of Hit and Trial, finally OP (JasonTsoum77) created a new Web Form from the Scratch and added the Labels again.

Surprisingly, it worked and issue is solved. :)
 
Share this answer
 
Hi,

The only thing I can think of besides redoing your sheets is maybe you are not typing the Label2 in the correct place in the CS file. I would try creating a method and placing the Label2 in there. Hope this helps!

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Label2.Text = "hello world";
}
 
Share this answer
 

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



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