DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    6

    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)
            {
     
            }
        }
    }

  2. #2
    Join Date
    Jul 2011
    Posts
    4
    Try to put CContact.cs file to App_Code folder.

  3. #3
    Join Date
    Oct 2008
    Posts
    141
    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

  1. Replies: 26
    Last Post: 12-01-2012, 04:12 AM
  2. Replies: 3
    Last Post: 04-19-2007, 06:44 PM
  3. Access 97 to 2000 Conversion Error
    By Michelle in forum VB Classic
    Replies: 8
    Last Post: 04-19-2002, 05:01 PM
  4. Access & SQL Server
    By David Jones in forum Database
    Replies: 0
    Last Post: 08-31-2001, 12:22 PM
  5. Replies: 0
    Last Post: 04-19-2001, 07:54 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links