views:

62

answers:

2

I have some classic asp code that needs converting to asp.net. So far I have tried to achieve this using datareaders and repeaters and had no luck as the menu loops through 4 different record sets, passing along the menuNid before moving to the next record.

Please can you tell me what method you would use to conver this code... i.e datareaders? dataset? etc?

Thanks

+2  A: 

well you have couple options there..

asp.net supports asp style notation, meaning <% %> etc are still supported.. and you could keep your code almost as is with some minor tweaking.. but you'd be missing out on 90% of what it has to offer. Namely the separation of markup and and code.

I recommend you familiarize your self with server control model in asp.net, and rewrite your pages to use that to get rid of all the % crap..

we can't teach you asp.net in a form answer, but server controls are the heart of the methodology there, so understanding them will bring you very close to getting a good idea in how to go about transitioning your stuff.. http://www.w3schools.com/ASPNET/aspnet_controls.asp

Sonic Soul
+2  A: 

Ouch... That's some slow and repetetive code... (Excuse me for being blunt...)

You could read all the data that you need into a DataTable (using a DataSet and a SqlDataAdapter) so that you can reuse it and don't have to run a query for every level and every item in the menu. That way you can have a single database call instead of a whole lot of them, and the database calls is absolutely the bottle neck in this code.

You could use recursion to get different levels, instead of repeating the same code over and over again.

To build the elements for the menu you have several options. One is to put a PlaceHolder in the page and create a tree of controls by adding them to each others Controls collection. Another option is to simply build the HTML code yourself in a StringBuilder, and put the result in a Literal control.

Guffa
Thanks for the help. its the worst spaghetti ive encountered! it was written in 2000.
Phil