-
I cannot access class inside ASP.NET Web Application !
Hello,
I start to created a new ASP.NET Web Application with VS 2005.
I created a sperate folder called "Classes" where I created my first class "CContact".
Then, I added a page "default.aspx" in order to display First name & Last name.
Unfortunately, I cannot access the class "CContact in the Page_Load() method when I try to type the following code: MyWebApp. ... The only class that i can see is "_Default"
What i'm doing wrong ?
Can anyone help me ?
Thank you
Paul
Code:
// -----------------------------------------------------------
// Class: CContact.cs
// -----------------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace MyWebApp
{
public class CContact
{
// Constructor
public CContact()
{
}
public static string FirstName()
{
return "John";
}
public static string LastName()
{
return "Travolta";
}
}
}
// -----------------------------------------------------------
// ASP.Net Page: default.aspx.cs
// -----------------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MyWebApp;
namespace MyWebApp
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
-
Try to put CContact.cs file to App_Code folder.
-
hi there,
inside Page_Load() try this:
private MyWebApp.CContact cls = new MyWebApp.CContact();
//get first name
Response.Write(cls.FirstName);
//get last name
Response.Write(cls.LastName);
that's it,
tonci korsano
Similar Threads
-
Replies: 27
Last Post: 02-11-2016, 05:29 AM
-
Replies: 3
Last Post: 04-19-2007, 06:44 PM
-
By Michelle in forum VB Classic
Replies: 8
Last Post: 04-19-2002, 05:01 PM
-
By David Jones in forum Database
Replies: 0
Last Post: 08-31-2001, 12:22 PM
-
By Tim Romano in forum .NET
Replies: 0
Last Post: 04-19-2001, 07:54 AM
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|