dynamic content from SQL

  • Thread starter Andrew Robinson
  • Start date
A

Andrew Robinson

Given HTML text (likely from SQL), is there any method that could be
employed to render server and/or custom controls that are contained inside
of that text? I would be loading content from a database and would like to
'expand' the server controls. Possibly even recursively.

Hope this makes sense, but I am guessing the answer is no.

If this is something that can't be done, I am looking at creating my own
markup tags and searching for them with Regular Expressions. Then rendering
them using my own custom classes. Does this seem like something that is 'way
out there' or rather mainstream?

-Andrew
 
S

Steve C. Orr [MVP, MCSD]

Sounds a lot like serialization, so you might want to look that up.
If that doesn't work, you could parse the text and create controls
dynamically as needed.

Dim tb as new TextBox()
SomePanel.Controls.Add(tb)
 
C

Craig Deelsnyder

Given HTML text (likely from SQL), is there any method that could be
employed to render server and/or custom controls that are contained
inside
of that text? I would be loading content from a database and would like
to
'expand' the server controls. Possibly even recursively.

Hope this makes sense, but I am guessing the answer is no.

If this is something that can't be done, I am looking at creating my own
markup tags and searching for them with Regular Expressions. Then
rendering
them using my own custom classes. Does this seem like something that is
'way
out there' or rather mainstream?

-Andrew

Have you looked at Page.ParseControl?

http://msdn.microsoft.com/library/d...ebuitemplatecontrolclassparsecontroltopic.asp

I assume you'll need to use this in the Init stage....Google on this
method name and I'm sure you'll find examples on how to use it. In fact,
I think there's one somewhere, an old WROX article about using XML w/ XSLT
and this method to allow the definition of pages without using any code,
just XML. Might be some good insight in that article you can use as well;
here, I just found it:

http://www.devarticles.com/c/a/ASP.NET/Creating-Dynamic-ASP.NET-Server-Controls-Using-XML
 
K

Kevin Spencer

Given HTML text (likely from SQL), is there any method that could be
employed to render server and/or custom controls that are contained inside
of that text? I would be loading content from a database and would like to
'expand' the server controls. Possibly even recursively.

The answer is yes, but some things that CAN be done SHOULD not. You could
dig yourself a swimming pool with a spoon, but it wouldn't be a good idea to
do so.

It seems to me that part of your problem is the way you view ASP.Net. It
sounds like you're coming from an ASP/Scripted/Procedural programming
background. Objects are not text, and you shouldn't treat them like text.
If this is something that can't be done, I am looking at creating my own
markup tags and searching for them with Regular Expressions. Then
rendering
them using my own custom classes. Does this seem like something that is
'way
out there' or rather mainstream?

Heck, it can't be mainstream, because I don't even know what you're talking
about. But it seems like you're trying to dig a swimming pool with a spoon
again. What sort of requirement is this gerrymandered technique soupposed to
fulfill?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
A

Andrew Robinson

Ok, here is more or less what I am exploring....

We have a couple of web servers at a few hosting facilities. A few hundred
to a few thousand unique visitors per day. Nothing extraordinary here. And
in all fairness, our server hardware is likely overkill. Our web content is
almost entirely static in nature. The current site is made up of about 150
pages.

The big issue is that while the content is static, it is being updated every
few days. We have html and image updates that need to go live at critical
time intervals. The updates are all driven by advertising and marketing.
There is a lengthy approval process where the site gets posted to a staging
server, approved by the powers that be and then it needs to go live at the
exact moment that advertising deems. Typically in the middle of the night
when the date rolls (and I am asleep).

I would like to explore putting content inside of SQL. The content can be
routed and approved as needed. Then replicated using either some type of SQL
replication or some type of home grown Web Service push/pull method.

Give the appropriate data structure, the site can now make content live when
the calendar rolls. I can put it up days in advance and not worry about it.

As I said before, the content is almost entirely static. Some text and a lot
of images and graphics. I was thinking of developing a set of custom
controls that would render text (html) or images and pull from SQL.

If I develop some type of Image and Text custom control that would be pretty
simple and maybe I will leave it at that. But, I think about maybe having
pages that are recursively generated where a html controls pulls from SQL.
The pulled page may contain other controls that need to be rendered /
expanded.

-Andrew
 
A

Andrew Robinson

I think this is very much what I was looking for.

If I use my own customer controls, will I have any issue resolving them to
the correct namespace?

Thanks much,

-Andrew
 
S

Steven Cheng[MSFT]

Hi Andrew,

Thanks for posting here. From my opinion, I also don't think dynamically
create server controls (or parse the string content with the asp.net
Parsing api) is not a good idea. Is it possible that you put all those
control declaratively? If there are cases that you can't get the definite
control items on the page, you can consider using some template databound
controls such as Repeater or DataList which can help generate a list of
control collections on the page according to the binded datasource.

In addition, after your page's dynamic content is generated, you can apply
the OutputCache on your page, this is a very important feature which can
help dynamic generated pages( content of which won't change frequently) be
serviced as quick as those static pages.

If there are any other ideas or questions, please feel free to post here.

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
K

Kevin Spencer

Thanks for the clarification.

If the content is static, there's no need to store any code in your
database. Static HTML isn't code; it's text.

I suppose the best way to describe what I'm getting at is, let's say you ran
a restaurant, and you expected the National Tea Drinkers convention to come
to your restaurant next week. So, you figure you need to stok up on tea. So,
you go out an buy a dozen tea decanters and put them in your walk-in
refrigerator. But wait! You don't need more decanters. You already have
enough decanters. All you need is to store the tea. So, you decide instead
to buy a single 50-gallon drum, put that in your walk-in, and have more
walk-in space.

In other words, if the content is static, and you already have ASP.Net pages
and Controls (decanters) that can serve the content to the client, there's
no need to store any process at all in your database. All you need to store
is the "tea" - the data, or content.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top