Jatin Asija
Jatin Asija

Reputation: 128

Identifier expected in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PageProcessingDemo
{
    public partial class  : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

i haven't done anything yet ,but it still showing " Identifier expected ",and pointing to ":" when double clicked.

Upvotes: 0

Views: 2659

Answers (1)

Farhad Jabiyev
Farhad Jabiyev

Reputation: 26665

You haven't specified class name. Change your code to something like this:

public partial class MyPageClass : System.Web.UI.Page

P.S: Also, you have said that:

i haven't done anything yet

I am pretty sure that somebody has removed name of the class.

Additional details: Try to add new WebForm to the project. Set the name of form to WebForm1.After clicking OK, VisualStudio will create three or two files depending on the type of the project:

  • WebForm1.aspx
  • WebForm1.aspx.cs
  • WebForm1.aspx.designer.cs (WebApplication project)

The *.aspx files are the markup and the *.aspx.cs files are the code-behind files. Code-behind files handle the .NET code for any server-side controls in the *.aspx files. And Asp.Net will generate your code behind files as partial classes like that:

 public partial class WebForm1 : System.Web.UI.Page

Upvotes: 9

Related Questions