asp.net, ado.net, c# question
-
Hello, I'm relatively new to c# and even newer to asp.net and ado.net. I'm trying to improve my skills in the asp.net and ado.net areas. I'm working on an a sample app where I want to display items in a web page based on what the user has selected from a drop-down list. A couple of questions I have while on this learning path: 1 -Are all database queries and "presentation" done within the .aspx files, or are some done in the .cs files? Thanks in advance. --------- Jeff
-
Hello, I'm relatively new to c# and even newer to asp.net and ado.net. I'm trying to improve my skills in the asp.net and ado.net areas. I'm working on an a sample app where I want to display items in a web page based on what the user has selected from a drop-down list. A couple of questions I have while on this learning path: 1 -Are all database queries and "presentation" done within the .aspx files, or are some done in the .cs files? Thanks in advance. --------- Jeff
Good question. In fact, your database queries SHOULD come from a seperate dll which encapsulates DB code. Microsoft have added ways to do database stuff in the ASPX, but no-one uses them except hobbyists and people who don't know/don't care about writing good code. You should run from any control that has you typing SQL into your aspx. You should try to wrap your database code into a seperate layer. Ideally, your database layer would not return database objects but take and return lists of classes in your project.
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
-
Hello, I'm relatively new to c# and even newer to asp.net and ado.net. I'm trying to improve my skills in the asp.net and ado.net areas. I'm working on an a sample app where I want to display items in a web page based on what the user has selected from a drop-down list. A couple of questions I have while on this learning path: 1 -Are all database queries and "presentation" done within the .aspx files, or are some done in the .cs files? Thanks in advance. --------- Jeff
Jeff, I like to break my design into three layers 1. Presentation 2. Business Logic 3. Database 1. In presentation layer I put only those that are of UI related. This will go directly into the aspx pages, user controls (usually I create on separate dll) and any UI related logic 2. Database. This is strictly database related classes. NO other code belongs here. 3. In business logic goes any middle-ware code that does not belong to any of the two categories. Now, notice how I said 'This goes to separate dll' in the first case. I don't go crazy in creating many dlls. The rule of thumb I use is, if the code can be reused somewhere else, then I create it in its logical dll, so I can easily take it to another project and reused. That means the other layers may have multiple dlls as well. Again, there are projects I have worked which they have only 2 layer or more than 3 layers. It does not have to be only 3 layers. The scope of the project will decide how you want to break your logical designs. In some cases you may be able to get away with single layer.
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
Jeff, I like to break my design into three layers 1. Presentation 2. Business Logic 3. Database 1. In presentation layer I put only those that are of UI related. This will go directly into the aspx pages, user controls (usually I create on separate dll) and any UI related logic 2. Database. This is strictly database related classes. NO other code belongs here. 3. In business logic goes any middle-ware code that does not belong to any of the two categories. Now, notice how I said 'This goes to separate dll' in the first case. I don't go crazy in creating many dlls. The rule of thumb I use is, if the code can be reused somewhere else, then I create it in its logical dll, so I can easily take it to another project and reused. That means the other layers may have multiple dlls as well. Again, there are projects I have worked which they have only 2 layer or more than 3 layers. It does not have to be only 3 layers. The scope of the project will decide how you want to break your logical designs. In some cases you may be able to get away with single layer.
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
Christian, Yusuf, thanks for your timely and informative replies. I have 2 simple (hopefully) questions that come to mind based on your responses: - You are both saying create separate .dlls. You do NOT mean the .cs files that are created in Visual Studio when you create a .aspx page, correct? - I've been through a couple of "introductory" books on c# and they all seem to show the database access code occurring in the .aspx file. That figures if they're just trying to show you enough to get started. I'll poke around in codeproject a lot more but: what would be the best way you all recommend to learn to create web sites the right way, using .dlls? Thanks again for your informative replies! -- Jeff
-
Christian, Yusuf, thanks for your timely and informative replies. I have 2 simple (hopefully) questions that come to mind based on your responses: - You are both saying create separate .dlls. You do NOT mean the .cs files that are created in Visual Studio when you create a .aspx page, correct? - I've been through a couple of "introductory" books on c# and they all seem to show the database access code occurring in the .aspx file. That figures if they're just trying to show you enough to get started. I'll poke around in codeproject a lot more but: what would be the best way you all recommend to learn to create web sites the right way, using .dlls? Thanks again for your informative replies! -- Jeff
jboyd111 wrote:
You are both saying create separate .dlls. You do NOT mean the .cs files that are created in Visual Studio when you create a .aspx page, correct?
- The .cs files modularize your code. In most cases If the class is big enough I put it in one .cs files, but if the class is small, then I combine logical classes together. - A dll is an assembly (or library) that contains certain functionality, for example Database layer Most books in programming jump into the topic in discussion they throw everything in one place. The idea is to teach the language not necessarily the design. So, take it with grain of salt. Here [^] are CP articles on design and strategy, should you need assistance don't hesitate to post your question in appropriate forum
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
jboyd111 wrote:
You are both saying create separate .dlls. You do NOT mean the .cs files that are created in Visual Studio when you create a .aspx page, correct?
- The .cs files modularize your code. In most cases If the class is big enough I put it in one .cs files, but if the class is small, then I combine logical classes together. - A dll is an assembly (or library) that contains certain functionality, for example Database layer Most books in programming jump into the topic in discussion they throw everything in one place. The idea is to teach the language not necessarily the design. So, take it with grain of salt. Here [^] are CP articles on design and strategy, should you need assistance don't hesitate to post your question in appropriate forum
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
Thanks Yusuf. I knew what dlls vs source (.cs) files were, I just hadn't seen .dlls used in any of the web (.aspx) examples I came across. I'm still trying to find where the actual compiled code from my web projects go, but that's another thread. Thanks for the pointer to the Design and Architecture articles and info. That should keep me busy for awhile :-) -------- Jeff
-
Thanks Yusuf. I knew what dlls vs source (.cs) files were, I just hadn't seen .dlls used in any of the web (.aspx) examples I came across. I'm still trying to find where the actual compiled code from my web projects go, but that's another thread. Thanks for the pointer to the Design and Architecture articles and info. That should keep me busy for awhile :-) -------- Jeff
jboyd111 wrote:
I'm still trying to find where the actual compiled code from my web projects go, but that's another thread.
Good question: In the case of dll you know where that goes. In the case of asp.net, the compiled code gets copied into framework temp folder which is located in
%WinDir%\Microsoft.Net\Framework\%version%\Temporary ASP.NET Files\%ProjectName%
where %windir% = windows directory (by default in XP c:\windows) %version% = Framework version (for example v2.0.50727) %projectname% = asp.net projectYusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
jboyd111 wrote:
I'm still trying to find where the actual compiled code from my web projects go, but that's another thread.
Good question: In the case of dll you know where that goes. In the case of asp.net, the compiled code gets copied into framework temp folder which is located in
%WinDir%\Microsoft.Net\Framework\%version%\Temporary ASP.NET Files\%ProjectName%
where %windir% = windows directory (by default in XP c:\windows) %version% = Framework version (for example v2.0.50727) %projectname% = asp.net projectYusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
Yusuf, my friend, you are my new hero! Thanks for taking the time to answer such rudimentary questions from a "newbie" such as myself. --- Jeff
It was real pleasure helping people like you. Feel free to post any further question you may have in appropriate forum. Good luck learning asp.net
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]