Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic web pages with ASP.Net 2.0 and javascript. 1

Status
Not open for further replies.

milliKidd

Programmer
Jul 24, 2008
10
US
Hello Tech Tip Experts,

Ok, here's my situation. It's a tricky one -- well, probably not for ya'll. I have a web page that I'm building that has address information on it. I currently have some textboxes on my form for address, city, state, zip, county, country, move-in date and move-out date. So, here's my dilemma, I have to gather 5 years of address history from our clients who will be filling out the form. Now, what I have so far is a little javascript code on my page that checks the dates to see if they have 5 years of history. If they don't, it pops up a nice pretty little jQuery modal box in the middle of the screen telling them we need more history. So then I have a link down at the bottom of the page that says "Add new address". Then the client can click the link and using scriptaculous and prototype I have it roll down a hidden div with more textboxes for address, city, state...etc. With me so far? Great. (-:

Ok, here's where I think I need to improve my web site. Currently, my HTML is a little over 1,300 lines long being I have enough textboxes to allow for about 6 sets of addresses. Whew, that's a LOT of HTML! So, I got to thinking, what if I were to have just that one set of textboxes at the top of my web form and using javascript to detect the move-in date of that one address, instead of popping the modal in the middle of the screen telling them to click the link and add more addresses, just create the textboxes dynamically for them to enter another address.

Is this possible? Can you use javascript with ASP.Net to do something like that?

I'm using Visual Studio 2005 with VB.Net and ASP.Net 2.0.

Thanks in advance, if you guys could steer me in the right direction I would appreciate it, I have combed Google looking for the answer without much luck. I have seen some code similar but just can't seem to find something that would suit my needs. Sorry, I am such a newb.

milli
 
1st i would consolidate your js libraries. protoype, scriptalious, jquery... pick one. this will make it easier to maintain in the long run. It's not different than if you created you're VS solution with C#, VB and IronPython. You can, but it creates a maintenance problem in the long run.

2nd, it sounds like you have all your code and html within 1 webform (3 project files). Again this creates a maintenance problem in the long run.

Rather than have everything you could possibly need for addresses within 1 webform separate them into webforms and user controls. You can use ajax to load the content without a full redirect.

as for scripting and webforms. I would recommend Rick Strahl's blog. He has a lot of content on the subject. depending on how far you are into your project I would also recommend looking into a MVC framework like MS MVC, FUBU MVC or Castle Monorail. I find they make web development much easier than WebForms.

one last side note:
asp.net != webforms.

asp.net is the framework for servicing request/response. it has nothing to do with rendering html. only fulfilling http requests. implementations of IHttpModule, HttpApplication, HttpContext, HttpRequest, HttpResponse, IHttpHandler, etc. all belong to the asp.net framework.

webforms is one option for rendering html. It runs on top of the asp.net framework and all it does is render html. This includes all the WebControls, Page, UserControl, Master along with a few other HTML specific objects.

this is an important difference when trying to understand web development using the .net framework.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Thanks Jason, that really got me to start thinking down some different avenues.

milli
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top