tags:

views:

33

answers:

1

I have a set of websites that basically do the exact same thing in terms of functionality, the only thing that varies is the css and how the html is laid out.

Is there a way to generate the html from a database (ie retreiving the html from a table) and then catching the controls (like buttons, textboxes etc) from the code behind?

UPDATE:

Here is an example of what I want to acheive:

<html>
<div id="generatedContent" runat="server">
<!-- the following content has been generated from the database on the page load event -->
<div>
     This is a textbox <input id="tb1" runat="server" type="text" />
     This is a button <input type="submit" id="btn1" runat="server" value="My Button" />
</div>
</div>
</html>

This is the code behind

var tb1 = new HtmlControls.HtmlInputText();
tb1 = FindControl("tb1");
var btn1 = new New HtmlControls.HtmlInputSubmit();
btn1 = FindControl("btn1");

Now obviously since the html has been generated from the database (ie after the page has already been initialised) the FindControl method will return null.

A: 

For static HTML content, you can easily add your content to your form by using LiteralControl like that :

Page.Controls.Add(new LiteralControl("<b>content from db</b>"));

EDIT : Your code-behind code (FindControl) should work if you put them in a form tag with runat=server attribute. But beware, your content should be added in every postback. Also you can get the values of your form elements by Request["FormElementId"].

Canavar
Not what I was looking for, Updated my question to further explain my scenario
Drahcir