CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > migration_to_asp.net.migrating_from_php_to_asp.net Tags:
Item Type: NewsGroup Date Entered: 5/17/2006 10:04:51 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 8 Views: 16 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
9 Items, 1 Pages 1 |< << Go >> >|
mrmatrix
Asp.Net User
Classes5/17/2006 10:04:51 AM

0/0

Ok, I'm sorry I am a php developer and I am looking into C#.NET and really interested. The only problem I am having is how the @*#(@ do I make and use classes in C#.NET???????

For example, if I had a class in PHP and I wanted to keep it in a separate file I wold just include the file so..

<?php
include('
classes/class.dbconnect.php');
$conn    = new DBConnect();
?>


But now, if I want to do the same thing in C#.NET how do I do that? I dont know how to bring in a .cs file... I'm SO CONFUSED!!! I keep finding tutorials about complieing this and that, but I can't do it on my Windows Home edition of my computer, but my hosting provider has ASP.NET 2.0. I dont know man... someone please explain this too me. Tell me what I need... dumb it down.

Right now all I need to do is understand how to bring in classes that I make. I can get everything else from there.
StrongTypes
Asp.Net User
Re: Classes5/17/2006 1:26:52 PM

0/0

It's actually very easy in .NET. For example, if you create a .cs file in the App_Code directory, you can use the code within it with no effort. Other than that, you might need to include a namespace.

i.e.

using MyNamespace.Blah

That's about it.

HTH,
Ryan


Ryan Olshan
Microsoft MVP, ASP.NET
Blog | Group | Website | Strong Coders Community

How to ask a question
mrmatrix
Asp.Net User
Re: Classes5/19/2006 7:01:54 AM

0/0

I'n having a bit of a problem trying to use class inside of name spaces.

I'm using these class inside of an aspx file. so

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" Debug="true" %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>

<%
/*using (YLU c = new YLU())
{
    Response.Write(c.SayHello());
}
*/
    YLU c = new YLU();
    Response.Write(c.SayHello());
//using System.GRC_RS;

    string [] hello    = {"John","Peter","Bobby","Jake","Tim","Will","Hello","Mike","Dave"};
    int [] hello1 = {1,32,32,3,232,4545,232,423,2232};
   
%>
<select id="hello" name="hello">
    <%
        int i=0;
        foreach(int val in hello1){
            string inner = hello[i];
    %>
    <option value="<%=val%>"><%=inner%></option>
    <%
            i++;
        }//end foreach
    %>
</select>
</body>
</html>

This is working if the class is NOT inside of a name space..

But if I put it inside of a namespace and call the namespace GRC_CS.. Then it doesn't work

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" Debug="true" %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>

<%
/*using (YLU c = new YLU())
{
    Response.Write(c.SayHello());
}
*/
    GRS_CS.YLU c = new GRS_CS.YLU();
    Response.Write(c.SayHello());
//using System.GRC_RS;

    string [] hello    = {"John","Peter","Bobby","Jake","Tim","Will","Hello","Mike","Dave"};
    int [] hello1 = {1,32,32,3,232,4545,232,423,2232};
   
%>
<select id="hello" name="hello">
    <%
        int i=0;
        foreach(int val in hello1){
            string inner = hello[i];
    %>
    <option value="<%=val%>"><%=inner%></option>
    <%
            i++;
        }//end foreach
    %>
</select>
</body>
</html>


It throws this error...

Compiler Error Message: CS0246: The type or namespace name 'GRS_CS' could not be found (are you missing a using directive or an assembly reference?)
StrongTypes
Asp.Net User
Re: Classes5/19/2006 7:29:06 AM

0/0

If you're using inline code, then you need to import namespaces as follows instead of a using statement.

<%@ Import Namespace="" %>

As for the error message, that means it's unable to find the namespace. Did you include the assembly that that namespace resides in in the bin directory?

Ryan


Ryan Olshan
Microsoft MVP, ASP.NET
Blog | Group | Website | Strong Coders Community

How to ask a question
mrmatrix
Asp.Net User
Re: Classes5/19/2006 12:13:59 PM

0/0

Sorry.. I'm really new to C#.. the cs file resides in:-

/App_Code/


And here is the contents of that file...

using System;

namespace GRC_CS
{

    public class YLU
    {
   
        private    string    sayhello;
   
        public YLU()
        {
            this.sayhello = "Hello World!";
        }//end YLU()
       
       
        public string SayHello()
        {
            return this.sayhello;
        }//end SayHello()
       
    }//end YLU :: Class

}//end GRC_CS

Remember, the aspx file is inside of:-

/cs/

So yea.. what is a directive reference, and what is a assembly reference?
StrongTypes
Asp.Net User
Re: Classes5/19/2006 1:31:07 PM

0/0

Don't know where the problem lies exactly. I just copied your code verbatum into a class inside of App_Code and could access the code.

Ryan


Ryan Olshan
Microsoft MVP, ASP.NET
Blog | Group | Website | Strong Coders Community

How to ask a question
mrmatrix
Asp.Net User
Re: Classes5/19/2006 2:13:55 PM

0/0

Hmm.. weird... ok.. this hosting platform I have supports both PHP and ASP.NET 2.0

When I got the hosting there was this directory in there with the following subdirectories

/aspnet_client/system_web/2_0_50727/

I can put files in there, but I can't run them. What is this folder all about?
StrongTypes
Asp.Net User
Re: Classes5/19/2006 3:13:31 PM

0/0

The aspnet_client directory has JavaScript files that are used for stuff like client-side validation. You shouldn't be putting your files in there. They should be in the root of the site.

Ryan


Ryan Olshan
Microsoft MVP, ASP.NET
Blog | Group | Website | Strong Coders Community

How to ask a question
mrmatrix
Asp.Net User
Re: Classes5/21/2006 8:58:13 PM

0/0

alright.., I gave up and bought a book.. it cleared up just about all my questions. The more and more I look into ASP.NET I like it.. but I know this might seem like a bad place to ask this question, but I figure who better to ask, but ASP.NET programmers.

What are the downfalls of ASP.NET?
9 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Classes in Modern Society Authors: Tom Bottomore, Pages: 128, Published: 1992
Characteristic Classes Authors: John Willard Milnor, James D. Stasheff, Pages: 330, Published: 1974
The Working Classes in Victorian Fiction Authors: P. J. Keating, Pages: 310, Published: 1971
English Verb Classes and Alternations: A Preliminary Investigation Authors: Beth Levin, Pages: 348, Published: 1993
The Dangerous Classes of New York, and Twenty Years' Work Among Them Authors: Charles Loring Brace, Pages: 504, Published: 2005
Dividing Classes: How the Middle Class Negotiates and Rationalizes School Advantage Authors: Ellen A. Brantlinger, Pages: 250, Published: 2003
The Psychology of Social Classes: A Study of Class Consciousness Authors: Richard Centers, H Dewey Anderson, Percy E Davidson, Pages: 244, Published: 1998

Web:
Class (computer science) - Wikipedia, the free encyclopedia In object-oriented programming, a class is a programming language construct that is used as a blueprint to create objects. ...
Social class - Wikipedia, the free encyclopedia Social class refers to the hierarchical distinctions (or stratification) between individuals or groups in societies or cultures. ...
Classes (The Java™ Tutorials > Learning the Java Language ... The introduction to object-oriented concepts in the lesson titled Object- oriented Programming Concepts used a bicycle class as an example, with racing bikes ...
What Is a Class? (The Java™ Tutorials > Learning the Java Language ... In object-oriented terms, we say that your bicycle is an instance of the class of objects known as bicycles. A class is the blueprint from which individual ...
WoW -> Info -> Classes After deciding what race to play, each character will choose one of several classes. Each race has its own list of class options available to it. ...
9. Classes Python's class mechanism adds classes to the language with a minimum of new syntax and semantics. It is a mixture of the class mechanisms found in C++ and ...
Classes (I) An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable. ...
Welcome to the PHP Classes Repository - PHP Classes Freely available programming classes of objects written with the web scripting language named PHP.
Schedule of Classes Tiger Web, Schedule of Classes. Spring, Maymester, Summer I, Summer II, Fall. All Courses by Subject, Spring, all courses by subject · Maymester, ...
Training-Classes.com - Training Seminars and Certification ... Training-Classes.com is a directory of training seminars, education, learning and development programs and providers. The directory includes all types of ...

Videos:
Rohan Classes In game with Rohan Online showing individual classes. Scout, Ranger, Templar, Guardian, Priest..etc i forget the others. Hope you Enjoy!
Java 06: Basic Classes Java 1.6 & Netbeans 5.5.1 beta
Geshe Michael Roach - Tibetan Language Classes 1-3 Geshe Michael Roach offering introductory classes to the Tibetan language with an emphasis on translating Buddhist texts from Tibetan.
Manic Street Preachers - The Masses Against The Classes Manic Street Preachers The Masses Against The Classes [promo video] Live - Manic Millenium 1999 Dir: Chris D'Adda
Geshe Michael Roach - Tibetan Language Classes 4-6 Geshe Michael Roach offering introductory classes to the Tibetan language with an emphasis on translating Buddhist texts from Tibetan.
CSS Tutorial // Div Layers, Classes This is a CSS Tutorial that will help you position an image using a div layer.
Mark Knopfler Master Class Part 1 (of 3) mkguitar.com Mark does a guitar lesson with 3 youngsters from the north-east in 1999.
Questions and Answers from the Bhagavad Gita Classes - Jyotish and Devi Novak Questions and Answers from the Bhagavad Gita Classes. The Essence of the Bhagavad Gita, Explained by Paramhansa Yogananda, As Remembered by His Disc...
Maria Callas Authority in the Master Classes Maria Callas singing in the Juilliard classes.
Classes on Bhagavad Gita The most loved and revered scripture in philosophical literature. It is one of the most sacred religious works of the Hindus, and yet, it not confine...




Search This Site:










asp in apache 2.0?

convert php script to asp.net

cron job or timer in iis / asp.net?

migration tool

converting from html

code to do the same as mysql_query, mysql_fetch_area and defining a session variable from one part of the mysql_fetch_array

about database thingy... anybody pls help!!

php

altering variables from sql then displaying

php http get chinese support problem

associated arrays => hashtable ?

retriving data from db and parsing

conditional include - php to asp?

asp.net is too expensive to deploy

help with php -> c# conversion.. binary unpacking...

how-to put data from a db into (for example) a session

how to translate it to .net

asp "wrapper" for php

pulling data from a database to put into a variable

migrating phpbb to asp.net forums

mailing list management

php to asp - equivalent to $http_get_vars

which is $_request[variable] similar contol in asp.net

php to asp

iterating throw a resultset

from php/mysql to asp.net

concatenating an iterator onto a string

writing a function in c#

$request

coming from a php + java background.

  Privacy | Contact Us
All Times Are GMT