Style/Approach Question

C

CJM

I'm converting a simple query/reporting page from ASP to ASP.NET as a
learning tool. A search box is presented to the user where they enter an ID
number to search for. The page posts back to itself, and a results table is
displayed showing the record requested - pretty simple stuff.

From what I can see so far, there are a number of ways of tackling this, and
probably a few that I dont know of yet(!). In ASP, the first thing I did was
determine whether the page had just been called or whether the form had been
submitted and results where needed. The program flow basically split the
page in two: If form submitted, show results, Else show initial page...

I could presumably follow the same approach in .NET, but I can see that a
number of alternatives are available. I could place the result table with
empty fields in the form from the start but hide it until the right time,
where the codebehind page would populate the table cell values... I could
place an empty table in the form (a placeholder effectively), and
dynamically add row & cells from the codebehind page... Or could dynamically
create both pages from scratch from the code...

I'm sure there are other alternatives asl well. Being fairly new to this,
it's hard to figure what the best approach is. I dont want my ASP background
to influence my design - I'd like to learn the best practices for .NET, and
I'm trying to cut out much of the inevitable trial & error that comes with
starting out. Most of the books & tutorials I have access to are rather
symplistic and rarely are demonstrations of good practice!

So given this scenario, what are the best approaches that you can recommend?
I realise much of this will be influenced by personal style & preferences.

Thanks in advance...

Chris
 
K

Kevin Spencer

The reason that there are so many ways of doing things is that there are
many types of web applications. How one is structured depends a great deal
upon the requirements. The best advice I can give you is to become familiar
with all of the aspects/components of ASP.Net, and design your app using the
most appropriate methods for fulfilling your app's requirements.

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

Steven Cheng[MSFT]

Hi Chris,

As for the best practice in ASP.NET you mentioned, I think as for such a
scenario-----------( get search info and display the search result in
page)------------generally , we can put some entry field controls and then
when user input data and submit the form, retreveing the datas and use a
web control to display the result datas.

And as Kevin has mentioned, in ASP.NET , there are many controls and
component you can use to finish such work. Also, to show the table
control(which display the search result), we also can make it created
dynacmially(after submit) or staticaly(hide it first before submit). Here
are some reference discussing on the related topics:

1. ASP.NET provide some good buildin template databound controls which can
help generate data displaying page. Here are some tech article introducing
this:

#Deciding When to Use the DataGrid, DataList or Repeater
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspnet-whenusedatawebcontrols.asp

#Creating Custom Columns for the ASP.NET Datagrid
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/creatingcustomcolumns.asp

#Creating Custom Columns for the ASP.NET Datagrid
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbconwebformscontrolstemplates.asp

2. As for put control on a asp.ne webform, we can add the control at
design-time in aspx page template or dynamically created at runtime. the
following tech articles may help you undertstanding it:

#Web Forms Code Model
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbconintroductiontowebforms.asp

#HOW TO: Dynamically Create Controls in ASP.NET by Using Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;317794

#Understanding ASP.NET View State
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/viewstate.asp

In addition, there are also many asp.net best practice and migration(from
ASP) reference, you may also have a look:

#ASP.NET Best Practices
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspnet-jspmig-aspnetbestpractices.asp

#ASP to ASP.NET Migration Guide
http://msdn.microsoft.com/asp.net/using/migrating/aspmig/default.aspx

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top