dynamic content from SQL

Discussion in 'ASP .Net' started by Andrew Robinson, Mar 2, 2005.

  1. 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
    Andrew Robinson, Mar 2, 2005
    #1
    1. Advertising

  2. 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)

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net



    "Andrew Robinson" <> wrote in message
    news:%...
    > 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
    >
    >
    Steve C. Orr [MVP, MCSD], Mar 2, 2005
    #2
    1. Advertising

  3. On Wed, 02 Mar 2005 15:57:00 -0600, Andrew Robinson <>
    wrote:

    > 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

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
    Craig Deelsnyder, Mar 2, 2005
    #3
  4. > 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.

    "Andrew Robinson" <> wrote in message
    news:%...
    > 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
    >
    >
    Kevin Spencer, Mar 2, 2005
    #4
  5. 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


    "Kevin Spencer" <> wrote in message
    news:...
    > > 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.
    >
    > "Andrew Robinson" <> wrote in message
    > news:%...
    > > 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
    > >
    > >

    >
    >
    Andrew Robinson, Mar 2, 2005
    #5
  6. 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

    "Craig Deelsnyder" <cdeelsny@no_spam_4_meyahoo.com> wrote in message
    news:eek:...
    > On Wed, 02 Mar 2005 15:57:00 -0600, Andrew Robinson <>
    > wrote:
    >
    > > 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
    >
    > --
    > Craig Deelsnyder
    > Microsoft MVP - ASP/ASP.NET
    Andrew Robinson, Mar 2, 2005
    #6
  7. 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.)
    Steven Cheng[MSFT], Mar 3, 2005
    #7
  8. 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.

    "Andrew Robinson" <> wrote in message
    news:...
    > 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
    >
    >
    > "Kevin Spencer" <> wrote in message
    > news:...
    >> > 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.
    >>
    >> "Andrew Robinson" <> wrote in message
    >> news:%...
    >> > 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
    >> >
    >> >

    >>
    >>

    >
    >
    Kevin Spencer, Mar 3, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J.Edwards
    Replies:
    0
    Views:
    1,660
    J.Edwards
    Jan 20, 2006
  2. Anonymous
    Replies:
    0
    Views:
    1,445
    Anonymous
    Oct 13, 2005
  3. hazz
    Replies:
    6
    Views:
    49,436
    SkyUCHC
    Jun 9, 2010
  4. ecoolone
    Replies:
    0
    Views:
    745
    ecoolone
    Jan 3, 2008
  5. Kurt
    Replies:
    0
    Views:
    181
Loading...

Share This Page