Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

partial class unable to access the asp.net objects

$
0
0

I have Default.aspx and Default.aspx.cs files. Default.aspx.cs contains partial class and is unable to access the objects in the Default.aspx.

Here is the Default.aspx file.

<%@ Page 

    Language="C#" 

    AutoEventWireup="true" 

    CodeFile="Default.aspx.cs" 

    Inherits="SimplePage.Default" %>

<!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 id="Head1" runat="server">

    <title>First Page Code-Behind</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    <asp:Button

        id="Button1"

        Text="Click Here"

        OnClick="Button1_Click"

        Runat="server" />

    <br /><br />

    <asp:Label

        id="Label1"

        Runat="server" />

    </div>

    </form>

</body>

</html>

Here is the Default.aspx.cs file
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace SimplePage
{
public partial class Default : Page
{
private void Page_Load(object sender, EventArgs e)
{
Response.Write(@"Hello #Develop<br>");
if(IsPostBack)
{
Label1.Text = "Click the Button";
}
}
}
}

 I am getting the following error when I compile. Here is the error.

 

The name 'Label1' does not exist in the current context (CS0103) - C:\CSExample\SimplePage\SimplePage\Default.aspx.cs:33,5


Viewing all articles
Browse latest Browse all 1764

Trending Articles