473,545 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about separating logic from html?

mca
Hi everyone,

I'm new to asp.net and i have a question about separating the html
code from the programming code.

i have an unknown numbers of entries in my table. I want to make a
hyperlink for every entry in my table. So i query the database and
get for example 3 entries back. So in a while loop i can make 3
hyperlinks with response.write( .......) etc.

For what i know of asp.net, it should be possible to query my database
in the upper side of the aspx-file (logic) and put the hyperlinks at
the bottom of the page (html). Could this be separated or do i have
to mix asp.net-code and html code (spaghetti)?

Anyone?

Regards,
Michel

Nov 18 '05 #1
3 1514
Hi

Have you looked at the asp.net server control DataGrid

If you have a DataSource with you, you can bind that DataSource to the DataGrid in the code behind
In the design side tell what are the columns required to display
thats al

at run time the DataBinding happens and you get what you desired

If you still need any info, please send me a email regarding the scenario you
are working
I will try to send u a code on tha

Kashyp
Aztec Software and Technology Services Ltd
Bangalore
Nov 18 '05 #2
> For what i know of asp.net, it should be possible to query my database
in the upper side of the aspx-file (logic) and put the hyperlinks at
the bottom of the page (html). Could this be separated or do i have
to mix asp.net-code and html code (spaghetti)?
Hi Michel,

When you speak of "the upper side of the aspx-file" and "the bottom of the
page (html)" you are thinking in classic ASP terms, which means
procedurally. In classic ASP, code is executed from top to bottom of the
page/script, which contains both server-side scripting, and HTML code.

ASP.Net is Object-Oriented, which means (among other things) that there is
no procedural order in which code is executed. Instead, objects are created,
and the execution thread is much more complex, passing among objects in a
non-linear fashion. It is more useful to think in terms of objects than
procedure with ASP.Net.

You can use a separate CodeBehind file, or put your CodeBehind code into the
ASPX Page Template in code blocks if you like. However, it is best to think
of the CodeBehind not as "the upper side of the aspx file," but rather as a
separate Class definition which can be optionally included in the same file
as the ASPX Page Template.

ASP.Net uses objects (Server Controls) to render HTML in the page. Any "raw"
HTML in the ASPX Page Template is converted at run-time to LiteralControls .
Other Server Controls are used for client-server interaction. These other
Controls have a server-side and a client-side aspect to them, and the
client-side aspect "talks to" the server-side aspect by means of form
PostBacks, since they don't "live" at the same time (the server-side objects
render the client-side HTML, and then go away until the next request. The
client-side HTML exists until a new Request is sent to the server).

Server Controls often do have a representation in the ASPX Page Template.
This representation in the Template file itself look similar to HTML or XML,
but at run-time they are rendered to the client as pure HTML. The HTML that
is rendered in the HTML document, however, looks nothing like the
server-side representation of the Control in the Template. Instead, it is
created by the server-side object (which is in the CodeBehind class of the
page) that is the "real" Server Control. The token in the Page Template is a
sort of placeholder, which can contain some code that builds the HTML
rendered at run-time, by combining information in the Server Control tag in
the Page Template with logic from the Server Control behind it.

In essence, this is how the Presentation tier of an ASP.Net app is divided
into presentation logic (Server Controls in the CodeBehind) and presentation
layout (the pseudo-HTML of Server Controls and "raw" HTML in the Page
Template).

I hope this clears things up for you somewhat.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"mca" <m_*******@hotm ail-dot-com.no-spam.invalid> wrote in message
news:40******** **@127.0.0.1... Hi everyone,

I'm new to asp.net and i have a question about separating the html
code from the programming code.

i have an unknown numbers of entries in my table. I want to make a
hyperlink for every entry in my table. So i query the database and
get for example 3 entries back. So in a while loop i can make 3
hyperlinks with response.write( .......) etc.

For what i know of asp.net, it should be possible to query my database
in the upper side of the aspx-file (logic) and put the hyperlinks at
the bottom of the page (html). Could this be separated or do i have
to mix asp.net-code and html code (spaghetti)?

Anyone?

Regards,
Michel

Nov 18 '05 #3
> asp.net-code and html code (spaghetti)
This is what we had with asp. Asp.net is designed to get rid of all that
spaghetti. The datagrid that Kashypa refered turns record sets into HTML
tables. All you have to do is a little ado.net setup and bind the data to
the datagrid. Look through the asp.net samples that ship with the .net sdk
for examples of binding to the datagrid and other controls.

Code behind allows you to move all your programming code into a seperate
file. Server controls allow you to wrap functionality into a resuable
component, like a shopping cart. There are lots of maginzines (eg. MSDN
Magizine) that are packed with tons of asp.net examples. Jeff Prossie's
"Programmin g .Net" book is a good introduction to .dotnet and asp.net.

ccallen

"mca" <m_*******@hotm ail-dot-com.no-spam.invalid> wrote in message
news:40******** **@127.0.0.1...
Hi everyone,

I'm new to asp.net and i have a question about separating the html
code from the programming code.

i have an unknown numbers of entries in my table. I want to make a
hyperlink for every entry in my table. So i query the database and
get for example 3 entries back. So in a while loop i can make 3
hyperlinks with response.write( .......) etc.

For what i know of asp.net, it should be possible to query my database
in the upper side of the aspx-file (logic) and put the hyperlinks at
the bottom of the page (html). Could this be separated or do i have
to mix asp.net-code and html code (spaghetti)?

Anyone?

Regards,
Michel

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
2080
by: Nunaya | last post by:
We have developed two objects called "customer" and "salesrep". For simplicity, assume that these two objects will talk directly to a database. The database has three tables: customers, customersalesreps (allows multiple salesreps to be associated with a customer), and salesreps. The customer object has business rules that allow...
11
2535
by: enki | last post by:
I am writing a game and I am having trouble with moving the character on the map. Here is what I have right now. It involves win32 programming but that not my problem. I would like some suggestions how I can make my code better. If you need more code I will post it. I am in early devlopment of the game. map.h:
6
1793
by: Chad Z. Hower aka Kudzu | last post by:
I want to do this. I want my programmers to do all the code. All of it - run at server and run at client. I then want a graphic artist to make the look and the layout of the pages. The graphic artists cannot use VS to edit the files. They will use any HTML tool of their choice.
11
2531
by: Peter M. | last post by:
Hi all, I'm currently designing an n-tier application and have some doubts about my design. I have created a Data Access layer which connects to the database (SQL Server) and performs Select, update, delete and inserts. I use dataset objects to pass data to and from the DAL. In my GUI (windows forms), I use databinding to bind controls...
5
1549
by: Ronald S. Cook | last post by:
We have a Windows app which contains UI code and all classes that perform business logic and make calls to database stored procs (located on a database server - i.e. not local to the app). My boss wants to bring all those classes to a business server and out of each instance of the Windows application (i.e. separate into a business tier). ...
9
1257
by: madpython | last post by:
I've been doing an application with Tkinter widgets. Nothing really fancy just routine stuff. Though I have no problems with it by now I guess it would be reasonable to ask about a thing that's been bothering me a bit. Look at this piece of code: class A(object): def a(self): return "a from A" class B(object):
1
1679
by: Griff | last post by:
Hi I'm not sure of the best way to go about achieving my goal and would appreciate any advice. What I would like to do is to generate a control that can be dropped onto a web page. For example, a control that provided catalogue information. As I envisage this, the control would be given a single argument (the end user identifier) and it...
35
1876
by: rebeccatre | last post by:
hi can Variant archiving setTimout('.. capability be done without using it? :-)
5
1273
by: Brad Pears | last post by:
I am really new to OO design and development pricipals and have a question... When developing vb.net applications using OO design principals I have read where you should be separating the data from the business logic (i.e. develop data classes AND business classes independantly). So does that mean that I should really develop a class for each...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7752
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5969
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.