views:

127

answers:

2

I have n pages with formviews, all sharing a similar layout inside their item/edit/insert templates.

For example all item and edit templates have a header and body part inside where i put the fields. The header has a certain style and the body part too.

My question is how can i enforce this style in all my formviews without repeating the same bulk css styles all the time.

Now i'm using masterpages for this with multiple formviews on 1 page. That's not good i think. I want one 1 page for edit/insert/item and 1 formview.

I would prefer somehow to define the style for edit template once and load it into every formview. Ofcourse not all the formviews have the same fields, so like masterpages i would like to have 'areas' where i can put my fields.

The perfect way i suppose would be to have a formview span a complete masterpage based page including the contentplaceholders inside it's edit/insert/item templates.

Any ideas are more than welcome.

Edit: I read it's possible in .Net 4 using dynamic data. I'm stuck with 3.5 for the moment.

A: 

You can use Themes(or Style Sheet Themes) and skins for this. For Example Create a theme Theme1 and a skin file under it with the following content.

<asp:FormView  runat="server" 
      RowStyle-BackColor="Blue" />

Now you can make pages in your application use the theme by entering the following in web.config.

 <pages theme="Theme1">

Also you can use RowStyle-CSSClass or EditRowStyle(to apply to edit template). You can also enter the style sheet file in the same Theme folder

josephj1989
Sorry but that's just not flexible enough for me.
Jeroen
+1  A: 

You could set a CSSClass for the form view or some other standard container than use child selectors in your CSS.

Mike Cellini
Did that. Ended up using a bunch of divs, separated all the styles into css. It's not perfect, but do-able.
Jeroen