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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

write html containg asp.net controls from database

Status
Not open for further replies.

ethorn10

Programmer
Feb 18, 2003
406
US
Based on my initial searches, I can't find anything that can help me out. For all I know, it might not even be possible but I'd love to think it is...

I have html stored in my database for certain pieces of a page. I'd like to have a "main page" with certain constant pieces of the page and then fill in the rest with the correct html from the database. I think this is possible with the literal control but my issue goes one step further. Some of the html contains .net controls (i.e. asp:label, asp:dropdownlist, etc.). The dropdownlists would need populated based on another select statement and all controls would need accessed when the page is submitted. Any ideas? Even if "you're crazy, that's not possible" is the result, I'd like to hear what you have.

Thanks.
 
you're crazy, that's not possible [smile]

Well, sort of anyway. What I don't get is why you need to have .NET controls. For example, if you write out any of the DropDownLists or Label controls then you wouldn't have any code to handle events for them. If they don't have to have any events then why use a .NET control as a HTML control will suffice.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks for the reply...

The idea is that I'll have all of these pieces of the page written out in their respective html (including .net controls which I'll come back to). I'll then have some knowledge (probably another table) of which pieces to display for the page that we're on AND I'll need some of the events associated with them. I could probably tolerate hard coding the dropdown elements into a <select> tag **shudder** but the main reason for the .net controls is to make use of the validator controls.

So let's say I have the following pieces of a page stored separately in a table somewhere:

firstname
lastname
address
city
state
zip
age
email

and let's also say that page1.aspx requires firstname, lastname, state, email (purely hypothetical here). State is the dropdown I could tolerate hard coding **shudder again**. But let's say that page2.aspx requires ALL of these elements and page3.aspx requires all of them AND puts a range on the age field. I was hoping I could store all of these little nuances in a table somewhere and write my stuff on the fly and have my cake AND eat it too :)
 
I can't see any reason why you can't achieve the effect you want, however, I'm not sure if it is possible using the method you've suggested.

What I think I would do in this instance, is create a User Control. This control could include all of the properties that you wish to display (i.e. the Labels, TextBoxes, DropDownLists etc) and would also have Public Properties that allowed you to both set the values of these controls and also choose whether they are visible or not.

The page that shows the User Control would just set these Public Properties when the Page Loads e.g.
Code:
myUserControl.ShowFirstName = True
myUserControl.FirstName = "Bob"
myUserControl.ShowLastName = False
etc...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Aha! I knew I was checking out the trees instead of that huge forest back there...

Thanks for the idea. I'll see what I can come up with and let you know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top