Re: Dynamic User Controls

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Martin Dechev (detcheff__at_hotmail.com)
Date: 09/22/04


Date: Wed, 22 Sep 2004 15:38:59 +0200

Hi,

You will have to parse the "html" (which happens to be a little bit more
than html) and add the controls by yourself. Let's suppose you have a method
that renders the "html" in question with the following signature:

public void Render(string content, HtmlTextWriter writer){}

You will have to parse the string in content. So, when you find pure html
(for direct output) do:

writer.Write(pureHtml);

When you find some control (i.e. WUCNews) you will have to first instantiate
it from the corresponding class:

WUCNews news1 = new WUCNews();

Then probably set some properties (you might need to parse some attributes):

news1.Page = Page;
news1.EnableViewState = false;
// etc...

And in the end render it:

news1.RenderControl(writer);

Hope this helps
Martin

"anthonyroche" <anthonyroche@ewiz.com.au> wrote in message
news:3847fcd6.0409211950.2e209073@posting.google.com...
> I have a web app (ASP.Net) using Templates with predominatly the body
> content stored in the db and displayed to screen using a PageID
> querystring. What I want to know is, if a content manager adds the
> tags
> <wuc:news id="News" runat="server"></wuc:news> into the body section
> via a CMS together with other page data (HTML content), how can I
> detect this tag (user control) and actually load it in the place
> he/she wants.
> Example HTML content loaded from db
>
> <table><tr><td>some text here</td></tr>
> <tr><td> more text maybe with images</td></tr>
> <!-- NOW I WANT THE NEWS USER CONTROL -->
> <tr><td><wuc:news id="News" runat="server"></wuc:news></td></tr>
> </table>
>
> I use a placeholder on the template page to pick up the string(above)
> that is stored in the DB which works fine. When I view source I can
> see the <wuc.. tag but ofcourse the news control is not rendered or
> loaded.
>
> Any ideas?



Relevant Pages

  • Re: oe6 reading mail showing as html raw source?
    ... > CWShredder, Ad-aware, Spybot, HijackThis ... > the Windows Profile is damaged, not OE or any identities, and, barring ... That control is, apparently, being fed from ... normal data and is being transcoded into HTML improperly. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re:
    syntax
    ... control categories Coward 9. ... "HTML", but my initial point is still true that there is no category ... and why your initial term "ASP.NET HTML Form Control" is incorrect). ... representation (and not accesible by the developer via server-side code). ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: syntax
    ... But you should not nitpick while posting mistaken information. ... "HTML" as I stated). ... "ASP.NET HTML Form Control". ... extremly limited server-side representation (and not accesible by the developer via server-side ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HTML Form value retrieval
    ... > I have an aspx page whose purpose is to read a customer-provided HTML ... Neither the "form" tag nor ... control of the form contents, and look and feel of the form. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Opening an HTML page with VB6
    ... The DOS window's purpose is to show debug messages and only opens when the engine detects some errors eg in the HTML or CSS code of a page. ... It is a demo of how to embed the HtmLayout control into an application. ... Its intention is to give you a tool that can render Html *you* have *control* over. ...
    (microsoft.public.vb.general.discussion)