CodeVerge.Net Beta


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




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > general_asp.net.getting_started Tags:
Item Type: Date Entered: 12/26/2004 4:28:19 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 10 Views: 13 Favorited: 0 Favorite
11 Items, 1 Pages 1 |< << Go >> >|
"hubert_chn" <>
NewsGroup User
object-oriented12/26/2004 4:28:19 PM

0

Hi, I am using C# to program a web application. Is it possible to create user-defined objects just like JAVA programming? For example, I have a class called HouseDB.cs, and a code-behind class called House.aspx.cs. I would like the HouseDB.cs acting as a simple database manager, ie,an entity class accessing database. Is it ok to put following code in House.aspx.cs?


House housesearch = new House()

then use housesearch.blahblah
to invoke House's methods.


I tried, but failed. Have no idea what has gone wrong...

"haidar_bilal"
NewsGroup User
Re: object-oriented12/26/2004 5:41:44 PM

0

Hello for sure, C# is an object oriented programming language. Which means that it follows OOP ideas. Maybe you have to have a look at :

C# OOP

regards
Bilal Hadiar, MCP, MCTS, MCPD, MCT
Microsoft MVP - Telerik MVP
"hubert_chn" <>
NewsGroup User
Re: object-oriented12/26/2004 6:33:27 PM

0

Yep... but the error said cant find data type "House". I know in JAVA, as long as u put class files in the same directory, the compiler will look for them automatically. But this seems not the case for C#. I then tried adding a "using" statement, something like:

using [namespace of House].House

But error remains, saying cant find [namespaceof House].House.

What should i do to make it find my House class? have I done anything wrong?

Thanks!
"Sharbel_" <>
NewsGroup User
Re: object-oriented12/26/2004 6:37:40 PM

0

Another fantastic book is C# Class Design Handbook : Coding Effective Classes .. i learned a lot from this book
"Jos Branders"
NewsGroup User
Re: object-oriented12/26/2004 6:53:53 PM

0

Yes, it is possible.

You have to add a reference to the house class to your aspx project (by rightclicking on it).

What's your error message?

Jos
"hubert_chn" <>
NewsGroup User
Re: object-oriented12/26/2004 8:03:18 PM

0

right, in my control class, lets call it ControlObj.cs, i have:

+++++++++++++++++
using DataLayer;

namespace ControlLayer
{
pulic class ControlObj
{
private DataObj mydata;
public ControlObj()
{
mydata = new DataObj()
}
......
}
}
+++++++++++++++++

then in my data entity class, lets call it DataOjb.cs, I have:

+++++++++++++++++
namespace DataLayer
{
using System;
using System.Data;
using System.Data.SqlClient;

public class DataObj
{
private String conn;

public DataObj()
{
conn = null;
}
}
}
++++++++++++++++++

But, every time the runtime complains "CS0246: cant find datatype or namespace "DataLayer". Error line: using DataLayer;" .(I am using Chinese version, but thats what the error means.)

I am completely lost here! This is a very simple example of 3-tier structure, which I copied with little change from the tutorial. But it just did not work! Please, can anyone help? I ve totally no clue and I am nuts.......

Any idea are appreciated!

Thanks very much!
"haidar_bilal"
NewsGroup User
Re: object-oriented12/26/2004 8:50:59 PM

0

You should compile the project first, create the DLL, and you should work fine, nothing wrong with your code.

regards
Bilal Hadiar, MCP, MCTS, MCPD, MCT
Microsoft MVP - Telerik MVP
"Sharbel_" <>
NewsGroup User
Re: object-oriented12/26/2004 8:57:49 PM

0

Did you set a reference to the assembly (DataLayer)??
"hubert_chn" <>
NewsGroup User
Re: object-oriented12/26/2004 9:50:12 PM

0

No, i think no. How should I set a reference to the assembly, please?
"augustwind" <>
NewsGroup User
Re: object-oriented12/26/2004 10:16:38 PM

0

What application are you using to create your application?
David Wier
MVP/MCP/ASPInsider
ASPNet101.com - where to look first!
iWrite Pro - doc/rtft to HTML/One Click PDF & much more
"hubert_chn" <>
NewsGroup User
Re: object-oriented12/26/2004 10:42:47 PM

0

I am using VS.NET 2003. But strictly speaking not a "project" because I did it by editing aspx and cs files manually and individually.

Also, I am using Mono to compile my code, and got following errors, plus questions:
(DataObj.cs)
Error:
++++++++++
DataObj.cs<17> error CS0246: The namespace System.Data can not be found.<missing assembly reference?>
DataObj.cs<18> error CS0246: The namespace System.Data.SqlClient can not be found.<missing assembly reference?>
Compilation failed: 2 error<s>, 0 warnings
++++++++++

Question:
How to do an assembly reference?
I compiled this using csc.exe, it generated a dll file, but still did not work.

Question 2:
In this case, the BusObj.cs uses DataLayer namespace and creates a DataObj object, so is it true that DataObj.cs must be compiled to make BusObj's compilation successful?

Big Thanks to everyone participates! Ya help are appreciated!
Thanks.
11 Items, 1 Pages 1 |< << Go >> >|


Free Download:













forms based authentication

retreiving id after post

new babie

project for firefox

c# and ubound

monitoring asp.net memory usage and execution time

url mapping and url rewriting

use of one class object in another class

vb public shared threatens go live date

ftp file upload between client browser and web server

store uploaded files on web server or in sql?

operator '>' is not defined for type 'dbnull' and type 'integer'.

passinf values between child and parent form

sending e-mails

"no overload for method 'getreader' takes '33' arguments"

adding records to a database

mappath to a parent directory?

how does the "write a new post" section work?

what wrong with this ??

find a special file in a directory

arrays

securityexception: request for the permission of type 'system.configuration.configurationpermission' failed.

help! first setup of sql server 2005 asp roles

damn "access is denied" error

asp.net pages not working on server

how to use a customcontrol that extends the validationsummary instead of default validationsummary

insert comma seperated values in table!..

deleting from two tables from at the same time

error when replace by regex, why ?

which comes first, the javascript or the code behind page?

can i load .dll dynamically?

web developer express

get data

retrive a file from a binary data field

data fetch in format

how to call webform control in usercontrol

hi hyperlink

client side programming

how to run .exe automaticaly in web?

compare ip address to a range

how to find the default cell width and height of a datagrid?

getting started with drawing

why the mail is not sending?

why does web matrix make a user control for sql server data connection?

repeat behavior

label right-aligned in html table cell?

setting focus to a textbox

custom error page

why to use xmldocument and xmltextreader together?

to get the detail of recently visited links in a site

   
  Privacy | Contact Us
All Times Are GMT