views:

72

answers:

2

Hi all, I am making my first web application with ASP.NET and I am having a rough time. I have previously created the application I am working on as a Windows Form application and it works great, but I am having problems with the HTML side of things in the web application. My issues are pretty minor, but very annoying. I have worked with websites before and CSS, but as far as I can tell I do not have direct access to a CSS when creating a web application in VS 2008. My biggest issue is the positioning of components that I have dragged onto the "Default.aspx" form. For instance, how am I supposed to float a panel next to another one if I don't have a CSS, or how am I to correctly position a label?

+1  A: 

You have a bit of a problem, if you want fine-grained (aka adequate) control over your css and markup. The Web-forms model was intended to "shield" you from these issues. Web forms and web controls can be very powerful in their ability to quickly deploy solutions, but there are some challenges:

  • you give up a lot control of your markup (although this will actually be getting better in 2010, with more sane control-generated markup and controllable id attributes.)
  • debugging can be difficult, since you can't fix a bug in the controls themselves. It's often difficult to find what is actually causing your bug.
  • what actually goes down to the browser can be huge, with a lot of extra markup that you didn't intend, don't need, and don't about until you "view source" on the client.

If you have not already investigated it, consider the ASP.NET MVP framework. We can now say that you have two main options when delivering web solutions with .NET, ASP.NET Webforms, and ASP.NET MVC. The MVC framework drops support for web controls, and helps you deliver your solution using the MVC pattern. This means several things, but for you it means a framework that assumes you want to define the layout yourself, and know the html going down to the browser.

Note that even in "classic" ASP.NET webforms (the type of project you've started with), you can still have control of your markup. If your .aspx page, just manually put the css and html that you want to have there. Using ASP "controls" is what really takes you away form your markup (and indirectly, from your CSS). A webforms project can have a great, efficient structure, but you have to provide it yourself.

Patrick Karcher
What do you suggest I do to get my components in the correct locations then?
typoknig
Don't uses the framework's "suggested" way of doing things, where you drag over asp controls. Or if you do use asp controls, put them in your own div tags and position those with CSS. The actual mark-up that goes down the the client will astound you, but it will all be in your div tags, and should render where you want it to.
Patrick Karcher
I guess I was just looking for a little more automation in my HTML generation. I have used Expression Web before and I was hoping VS would be a little more like that with the way HTML is managed. Took a while but I just entered my HTML tags manually like you suggested and everything is coming together alright apart from a few functions that exist in Windows Forms but not in the Web Applications.
typoknig
A: 

Please check out the Getting Started Videos for getting into ASP .Net. To layout your form it is the same with HTML. You may have to put Divs, Tables or such and to make it more presentable you should use CSS. ASP .Net has a great deal of features like Masterpages and controls like GridViews, Listviews etc. to make development of web pages simple.

HTH

Raja
Thanks for the link, I'll start watching now.
typoknig