GH,
If you need help let me know, I wrote a CMS type app myself. Also
doing the regular expersion may work, but I implemented it by
building the HTML page and doing on a parsecontrol on the string. In
the end you should be able to paste the html into a page and the page
work correctly. If you user parsecontrol on the following, it will
display a server side button
<table><tr><td><asp:button .... /></td></tr></table>
James
YES! Thank you so much! You clearly understand my objectives. While
I haven't yet implemented it, I'm sure it will work.
-GH
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message
Seems like I had a hard time posting that last night
James idea might be useful (to use ParseControl)...
Given an html string as follows:
"<table><tr><td>{button}</td></tr></table>"
where {button} is the location you want to insert an ASP.Net button
(and "{button}" is actually in the string), you could use regular
expressions to brake the string up so that you have the following
three matches:
"<table><tr><td>"
"{button}"
"</td></tr></table>"
you could loop through the collection of matches
for each match in matches
dim control as Control
if match.startswith("{") and match.endswidth("}") then
if match == "{button"}then
control = new Button();
...
else if match == "{linkbutotn}" then
...
end if
else (match isn't {XXX}) then
control = new Literal()
ctype(control, Literal).Text = match (just make it equal to
the
text)
end if
if not control is nothig then
myContentPlaceholder.Controls.Add(control)
end if
next
Does something like that make sense? Does it work in your case?
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup
FAQ (more to come!)
<< My guess is that if you need to do this, there's probably a
better way.
Yes - I agree that typically there is probably a better way; but
here's why I don't see much of a way around this: What I have is a
CMS that lets users enter new content via a Rich Text editor. That
editor outputs HTML which gets inserted into a database. Later I'm
injecting that HTML into a templated ASP.NET page (actually into a
User Control) -- and I'm injecting it via the Literal as described
in the OP. It is into the user-supplied HTML that I want to imbed
another Server control.
I really need to find a way to do this and I believe there might
be - even if it requires me reworking how my ASPX pages are
constructed. So, if you or others could hang in with me on this
and provide additional possibilities I'd be eternally greatful -
whatever that's worth
So, what I'm currently doing is this:
1 -- I have an ASPX page that does little more than hold an HTML
table that is used for placement of four (4) User controls: one
for the page's header, another for the footer, another for the
navigational menu, and one for the content area.
2 -- At runtime, the ASPX loads the various User controls into
their locations via Placeholder controls.
3 -- The content area's ASCX's code-behind logic retrieves the
user-supplied HTML snippet from the DB and injects it into the
correct location via the Literal control.
It is into that HTML snippet that I want to insert an additional
server control and manipulate its properties server-side before
sending the page down to the client.
I really need to make this happen - even if I have to rework the
app in order to get this result.
Thanks!
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message
I don't think that's possible. You can't parse a string into
server side controls...there _might_ be a 3rd party control to do
this, but I doubt it. My guess is that if you need to do this,
there's probably a better way. PEople typically create things
dynmaically via code such as:
HtmlTable table = new HtmlTable();
HtmlTableRow row = new HtmlTableRow();
Table.Controls.Add(row);
....
obviously that won't work from a string such as
<table><tr><td></td></tr></table> as you'd have to parse that
out....
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ
(more to come!)
In an ASCX, I have a Literal control into which I inject a
[string of HTML] at runtime.
litInjectedContent.Text =
dataClass.GetHTMLSnippetFromDB(someID);
This works great as long as the [string of HTML] contains just
client-side HTML, CSS, etc.
What I want to do is somehow insert a *server control* into the
[string of HTML], then set the server control's properties at
runtime.
Specifically: suppose the [string of HTML] is a simple and empty
one-cell HTML table: <table><tr><td></td></tr></table>
At runtime I'd like to be able to inject that string (the HTML
table) into the ASCX via the Literal control (litUserContent) -
AND THEN insert another Server control into the empty <TD></TD>.
The "other server control" could be anything with runat=server.
e.g., a TextBox
Is this even possible? If so, how can I accomplish this?
FWIW: the [string of HTML] could contain some flag text that
indicates the location in the [string of HTML] into which the
new "other server control" is to be placed.
Thanks!