tags:

views:

91

answers:

4

What is the recommended way of designing asp.net web forms using div and span. Assume that we want to design an input form for creating new customers, where it includes name, birth date, education etc.

Considering the above scenario, how div and span could be used for achieving seperation of concerns: seperation of presentation from content. We would like to define a form from the content perspective. Once a content and structure is in place, some designer can develop CSS and apply to it.

Please help. Thanks in advance.

+2  A: 

There are many tutorials out there that show how to design css forms. IMHO it's more a matter of labels and inputs than divs and spans.

Darin Dimitrov
As a non-designer developer do we have to take any care while working with those labels and inputs?
Anand Patel
Yes, you need to place them inside your web form as asp.net controls.
Darin Dimitrov
I believe, I have not done a good job on framing the question well. Let me try in this way. I have the following form:<form runat="server">Enter your name:<asp:TextBox id="txt1" runat="server" />Enter your Birth Date:<asp:TextBox id="txt2" runat="server" /><asp:Button OnClick="submit" Text="Submit" runat="server" /></form>Where and why exactly I should place the div and span tags and why?
Anand Patel
I believe that Darin has answered your question.
IrishChieftain
@Anand, there's no need to put divs and spans in your case. Just wrap the text into labels which will be associated to the input and that should be it: `<label for="txt1">Enter your name:</label><asp:TextBox id="txt1" runat="server" />...`
Darin Dimitrov
A: 

It is hard(but not impossible) to achieve full separation of concerns with asp.net web forms, it is lot easier to do it with asp.net mvc because of cleaner generated html...anyway, you have few options here...

-you can create user control with fields that you need, maybe generating inputs and labels dynamically on certain condition and then put it on your pages where you need it...for asp.net web forms world, it is fine separation

-you can try to build class for generating pure html with your labels and inputs..you will pass to the class list of properties with types(string, number) and class would know for which property to generate which label and which input field and you will render pure partial html on your page

cheers

Marko
+2  A: 

<div> defines a rectangle, and forces a line break afterwards.

<span> is a sequence of characters, and does not force a line break.

<asp:Panel> generates a <div>

<asp:Label> generates a <span>

Which one you use where depends entirely on what you want your form to look like.

RickNZ
A: 

please check this is full example to build web form using css3 and html5 http://bit.ly/brbTDz hope helps you

Waleed Mohamed