Forum Moderators: open

Message Too Old, No Replies

ASP.Net Theory

         

haggul

3:32 pm on Jan 18, 2007 (gmt 0)

10+ Year Member



Apologies if this has been covered but I have tried to search and not found exactly the answer I need.

I'm in the process of redeveloping a large classic ASP site into .Net - and you guessed it this is my first foray into the brave new world!

I have built my template in CSS, and converted to Master Page / Content Page setup - so far so good.

However I just need to check what the general approach should be with regards inserting the dynamic content.

In classic ASP I would have opened up a recordset near the top of the page, and either used Response.write or <%=blah%> to get my dynamic content out onto the page.

In .Net whilst experimenting I have got it talking to SQL, and displaying data in either a gridview or formview. This doesn't seem to suit my fairly complex product page layout I would like to achieve.

Therefore what is the best way to insert dynamic data on a fairly complex page layout - one that is broken down into lots of distinct sections, and may require nested "recordsets" at certain points?

Can I still open up a "recordset" at the top of the page and refer to it throught the page? Should I be using Literals or Labels or similar?

I would kind of like to use the Code Behind model (if it's appropriate in this instance) as I plan to do so going forward anyway (unless any reasons not to?)

I have a book but the entire chapter of displaying data on a page comprises gridview, detailview and formview and they seem so alien at present!

Going forward should I be using the repeater control etc etc for my listing pages?

Many Thanks in advance for any assistance.

TheNige

8:18 pm on Jan 18, 2007 (gmt 0)

10+ Year Member



Take a look at the repeater and datalist controls. With the repeater you make your own template and can repeat the data how you want...not simply in a grid. You can also nest repeaters so that the nested repeater is dependent on data from the datarow in the parent repeater.

In ASP.Net we don't really use the recordset object anymore. Get your data and bind it using the datareaders, datatables or dataset objects in your code behind.

[edited by: TheNige at 8:20 pm (utc) on Jan. 18, 2007]

centime

8:36 pm on Jan 18, 2007 (gmt 0)

10+ Year Member



asp.net is correctly described as a totally different, programming paradigm. I had to completely restructure everything i had previously done in classic asp

But, it was worth it

Try to learn the asp.net way of doing thing because it offers solutions that you might otherwise miss out on,

If you do try to mix asp classic coding systems, using recordsets for example, you will get unpredictable results, plus i found there is very little literature about trying to make asp an asp.net coexist it the same application

Once you start down the asp.net route, tis all the way :)

enjoy

haggul

10:44 am on Jan 19, 2007 (gmt 0)

10+ Year Member



Cheers guys - I definitely want to go down the "right road" and not just rehash the spaghetti of classic ASP.

So in the case of a "product page" when I have title, image, description, price etc as a one off, and then perhaps bulk discounts, related items, pdf data sheets as possible nested recordsets what would I use to "house" the single product information for example?

In the case of binding the data from the code behind, what do I bind the returned values to? Do i use labels or literals or similar to replace with my dynamic content.

I take it from what I have read I can include a whole chucnk of CSS/HTML markup inside most of these controls (repeater etc)?

As I say I want to start out on the right foot as I have learned from experience that starting off in the wrong direction means the journey just gets longer and longer!

Thanks again.

haggul

12:29 pm on Jan 19, 2007 (gmt 0)

10+ Year Member



Edit to above :

Have downloaded some of the starter kits from Asp.net site and think it might be giving me some idea - although e-comm example I got was in C# I think I got the gist of some of it!

It seems like their product page is interspresed with labels/literals and the C# version of the Page load code just populates those.

Using this approach do I just open up a connection and datareader using ADO.Net and then assign the returned values into the controls?

Whats the rule of thumb with regard the use of a label over a literal?

Cheers anyone whos looking at a Newb make an idiot of themselves!

tufftybloke

9:37 am on Jan 23, 2007 (gmt 0)

10+ Year Member



Hi

I have just started moving to asp.net too after being a classic asp developer for several years. Its a bit of a learning curve but I have decided to write it all in C# too.

I am converting a current asp web application at the moment, I have used master pages and code behind which is surprisingly easy to do.

I think the biggest hurdle for a classic ASP developer will be classes. I have used a class to render elements on a page and built a class to handle the database calls returning datatables or datareaders.

In asp, I wrote a dbwrapper that did the DB connection stuff and would get it to read the recordset into an array using getrows() as this was faster and neater than using recordsets all over the place. Using a dataset is similar but I only use datasets when I need to return values from a stored procedure otherwise I tend to use a datareader as its faster.

I use literals in the aspx page as place holders for the dynamic content and in the code behind populate them by using my pagefunctions class.

It can get a little confusing but I think I am getting there. I am not saying the way I do stuff is right but it does work and everything is logically placed.

Hope that helps a little, there seems to be so many different ways to achieve a task in asp.net, classic asp was pretty simple in comparison.

<tuffty/>

haggul

11:51 am on Jan 24, 2007 (gmt 0)

10+ Year Member



Thanks tufty

I too use getrows in my classic ASP (and I do some PHP) so hopefully using the new methods (which I assume is very much like dealing with arrays) won't be too much of a headache! I do some VBA programming so can get to grips with classes I hope! I think I now have some direction at least!

Cheers.