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: 18 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:













contents of master page doesn't appear in the contents of the content page !!

seo friendly for sharepoint?

server side forms, using more than 1 per page

button.validationgroup property

copy from excel and paste it in textboxes

app_data folder with sql server 2005

dropdownlist bug?

detecting dead links and unreferenced pages

using third party tools

need help converting c# to vb.net

need help performing a loop for sending email attachments:

can create text file, but can not update or delete??

in asp.net can i use a combo box as a text box and picklist

top aligning a gridview control

asp.net fun stuff for april fools' day :-)

what is a 'class'

page freezes after adding update panel

streamreader vs textreader

split a post into more pages - how to do it?

webservice, backgroundworker or simple threading?

progress bar control - rob howard

create thumbnails of big pictures?

regular expression help

set start page editiing webconfig?

how to: add a parameter in code?

newbie question

user input data to xml

properties and events

aspnet_wp.exe stopped unexpectedly

how to write a dynamic log/protocol mechanism?

code upgraded to 1.1

calendar control

linking to vb.net dll

retrieving netbios name of web server.

how files are arranged asp.net

order form using datagrid

help!!

how to work around the access denied cross-domain frame issue in asp.net ajax 1.0

how to add dynamic data into treenode

vb.net vs c#

how to connect smtp server on .net 2003

library system sample

merge controls when hide the middle between them

moving .aspx pages to another project.

changing the src of an html img from .aspx code

multithreading - using application/session/cache for storing data ...

title and meta tags of page

rookie: administering a windows server (for the first time) for her web app, please recommend a book

submit button

weird field validation problem

   
  Privacy | Contact Us
All Times Are GMT