473,491 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Insert Server Control Into HTML String (via Literal) at runtime

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!
Nov 19 '05 #1
20 5593
a

--
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!

Nov 19 '05 #2
a

--
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!

Nov 19 '05 #3
I don't thin that'

--
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!

Nov 19 '05 #4
I don't thin that'

--
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!

Nov 19 '05 #5
a

--
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!

Nov 19 '05 #6
a

--
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!

Nov 19 '05 #7
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!

Nov 19 '05 #8
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!

Nov 19 '05 #9
<< 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 news:%2****************@TK2MSFTNGP09.phx.gbl...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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!


Nov 19 '05 #10
<< 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 news:%2****************@TK2MSFTNGP09.phx.gbl...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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!


Nov 19 '05 #11
Instead of using a Litercontrol use a placeholder control and then when
your loading your data use the ParseControl method of the placeholder to
insert your html/server side controls.

"Guadala Harry" <GM**@NoSpam.net> wrote in
news:#J*************@TK2MSFTNGP09.phx.gbl:
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!


Nov 19 '05 #12
Instead of using a Litercontrol use a placeholder control and then when
your loading your data use the ParseControl method of the placeholder to
insert your html/server side controls.

"Guadala Harry" <GM**@NoSpam.net> wrote in
news:#J*************@TK2MSFTNGP09.phx.gbl:
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!


Nov 19 '05 #13
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:eo*************@TK2MSFTNGP15.phx.gbl...
<< 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 news:%2****************@TK2MSFTNGP09.phx.gbl...
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!



Nov 19 '05 #14
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 news:%2****************@tk2msftngp13.phx.gbl...
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:eo*************@TK2MSFTNGP15.phx.gbl...
<< 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 news:%2****************@TK2MSFTNGP09.phx.gbl...
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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!



Nov 19 '05 #15
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

"Guadala Harry" <GM**@NoSpam.net> wrote in
news:e2*************@TK2MSFTNGP14.phx.gbl:
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 news:%2****************@tk2msftngp13.phx.gbl...
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:eo*************@TK2MSFTNGP15.phx.gbl...
<< 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
news:%2****************@TK2MSFTNGP09.phx.gbl...
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
> 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!
>
>




Nov 19 '05 #16
Thanks James. I got it to work by doing the following:

ContentPlaceHolder.Controls.Add(litUserContent1);
ContentPlaceHolder.Controls.Add(myUserControl);
ContentPlaceHolder.Controls.Add(litUserContent2);
Basically I split the user-supplied HTML into two strings, then inject it
via Literal controls litUserContent1/2, with the server-side user control
getting added between.

It works - but if there is a better, more elegant, better performing, or
more easily maintained approach, I'd like to see it.

Thanks again for your feedback.

-GH

"James Doughty" <in*****@email.com> wrote in message
news:Xn*****************************@199.45.49.11. ..
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

"Guadala Harry" <GM**@NoSpam.net> wrote in
news:e2*************@TK2MSFTNGP14.phx.gbl:
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 news:%2****************@tk2msftngp13.phx.gbl...
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:eo*************@TK2MSFTNGP15.phx.gbl...
<< 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
news:%2****************@TK2MSFTNGP09.phx.gbl...
>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!)
>
>
> "Guadala Harry" <GM**@NoSpam.net> wrote in message
> news:%2***************@TK2MSFTNGP09.phx.gbl...
>> 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!
>>
>>
>
>


Nov 19 '05 #17
I'm not sure why you splitting the users control into 2 pieces, but if
your smyUserControl is know you can add it to the page. I've not had a
real issue with speed but none of the page are very graphic intensive.

As far as elegance it all depends on your needs, I'm using a XML Document
to create part of the pages I generate, I have all the data/controls
stored in a database and I'm using a webservice to retrueve the html
page.(yes the webservice is slow on the intiall load of the page but I
like the fact I if I need to redeploy this piece the users will more than
likely never see a glith on the system)

I'm also curious what are you using as the HTML editor?

James Doughty

"Guadala Harry" <GM**@NoSpam.net> wrote in
news:uf**************@TK2MSFTNGP15.phx.gbl:
Thanks James. I got it to work by doing the following:

ContentPlaceHolder.Controls.Add(litUserContent1);
ContentPlaceHolder.Controls.Add(myUserControl);
ContentPlaceHolder.Controls.Add(litUserContent2);
Basically I split the user-supplied HTML into two strings, then inject
it via Literal controls litUserContent1/2, with the server-side user
control getting added between.

It works - but if there is a better, more elegant, better performing,
or more easily maintained approach, I'd like to see it.

Thanks again for your feedback.

-GH

"James Doughty" <in*****@email.com> wrote in message
news:Xn*****************************@199.45.49.11. ..
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

"Guadala Harry" <GM**@NoSpam.net> wrote in
news:e2*************@TK2MSFTNGP14.phx.gbl:
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
news:%2****************@tk2msftngp13.phx.gbl...
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!)
"Guadala Harry" <GM**@NoSpam.net> wrote in message
news:eo*************@TK2MSFTNGP15.phx.gbl...
> << 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
> news:%2****************@TK2MSFTNGP09.phx.gbl...
>>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!)
>>
>>
>> "Guadala Harry" <GM**@NoSpam.net> wrote in message
>> news:%2***************@TK2MSFTNGP09.phx.gbl...
>>> 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!
>>>
>>>
>>
>>
>
>



Nov 19 '05 #18
<<I'm not sure why you splitting the users control into 2 pieces>>
Actually I have a number of user controls in play here, and none are getting
split, themselves. What IS getting split is some HTML text (supplied by the
user via a rich text editor) that gets injected into one of the user
controls; and it's getting split ONLY so I can insert another user control
in the middle of that HTML.
The end result of this is that the user can create some HTML content. They
can enter some special "flag text" that indicates where a content rotator
should go. The final result is that they get a content rotator in the middle
of their content - and they don't have to know how to create the content
rotator. All they have to do is know how to specify the special "flag text"
correctly and place it where they want it. FWIW: That content rotator is
contained within the user control that I'm injecting into the middle of the
HTML text.
Sample:
"<table><tr><td>{ContentRotatorHere}</td></tr></table>"
The user creates the above complete HTML string - which gets saved to a
database. This is a gross oversimplification of course. Then, when it's time
to display their content elsewhere in the app - I pull that HTML string out
of a database, split it into two strings - one before "{ContentRotatorHere}"
and the other for what comes after it; then I insert the two "HTML strings"
into a Placeholder control along with the user control that contains the
content rotator. I add the HTML via two Literal controls, and add the
content rotator's containing user control between them in the Placeholder
control. This all actually works! It's a lot going on - but with a healthy
dose of Caching runtime performance is great.

<<I'm also curious what are you using as the HTML editor>>
A heavily customized implementation of CuteEditor which you can see at
www.CuteSoft.net

-GH
"James Doughty" <in*****@email.com> wrote in message
news:Xn*****************************@199.45.49.11. ..
I'm not sure why you splitting the users control into 2 pieces, but if
your smyUserControl is know you can add it to the page. I've not had a
real issue with speed but none of the page are very graphic intensive.

As far as elegance it all depends on your needs, I'm using a XML Document
to create part of the pages I generate, I have all the data/controls
stored in a database and I'm using a webservice to retrueve the html
page.(yes the webservice is slow on the intiall load of the page but I
like the fact I if I need to redeploy this piece the users will more than
likely never see a glith on the system)

I'm also curious what are you using as the HTML editor?

James Doughty

"Guadala Harry" <GM**@NoSpam.net> wrote in
news:uf**************@TK2MSFTNGP15.phx.gbl:
Thanks James. I got it to work by doing the following:

ContentPlaceHolder.Controls.Add(litUserContent1);
ContentPlaceHolder.Controls.Add(myUserControl);
ContentPlaceHolder.Controls.Add(litUserContent2);
Basically I split the user-supplied HTML into two strings, then inject
it via Literal controls litUserContent1/2, with the server-side user
control getting added between.

It works - but if there is a better, more elegant, better performing,
or more easily maintained approach, I'd like to see it.

Thanks again for your feedback.

-GH

"James Doughty" <in*****@email.com> wrote in message
news:Xn*****************************@199.45.49.11. ..
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

"Guadala Harry" <GM**@NoSpam.net> wrote in
news:e2*************@TK2MSFTNGP14.phx.gbl:

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
news:%2****************@tk2msftngp13.phx.gbl...
> 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!)
>
>
> "Guadala Harry" <GM**@NoSpam.net> wrote in message
> news:eo*************@TK2MSFTNGP15.phx.gbl...
>> << 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
>> news:%2****************@TK2MSFTNGP09.phx.gbl...
>>>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!)
>>>
>>>
>>> "Guadala Harry" <GM**@NoSpam.net> wrote in message
>>> news:%2***************@TK2MSFTNGP09.phx.gbl...
>>>> 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!
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Nov 19 '05 #19
Sounds like your well on your way, I can't think of anything else.

Good luck,
James
"Guadala Harry" <GM**@NoSpam.net> wrote in
news:uG**************@TK2MSFTNGP09.phx.gbl:
<<I'm not sure why you splitting the users control into 2 pieces>>
Actually I have a number of user controls in play here, and none are
getting split, themselves. What IS getting split is some HTML text
(supplied by the user via a rich text editor) that gets injected into
one of the user controls; and it's getting split ONLY so I can insert
another user control in the middle of that HTML.
The end result of this is that the user can create some HTML content.
They can enter some special "flag text" that indicates where a content
rotator should go. The final result is that they get a content rotator
in the middle of their content - and they don't have to know how to
create the content rotator. All they have to do is know how to specify
the special "flag text" correctly and place it where they want it.
FWIW: That content rotator is contained within the user control that
I'm injecting into the middle of the HTML text.
Sample:
"<table><tr><td>{ContentRotatorHere}</td></tr></table>"
The user creates the above complete HTML string - which gets saved to
a database. This is a gross oversimplification of course. Then, when
it's time to display their content elsewhere in the app - I pull that
HTML string out of a database, split it into two strings - one before
"{ContentRotatorHere}" and the other for what comes after it; then I
insert the two "HTML strings" into a Placeholder control along with
the user control that contains the content rotator. I add the HTML via
two Literal controls, and add the content rotator's containing user
control between them in the Placeholder control. This all actually
works! It's a lot going on - but with a healthy dose of Caching
runtime performance is great.

<<I'm also curious what are you using as the HTML editor>>
A heavily customized implementation of CuteEditor which you can see at
www.CuteSoft.net

-GH
"James Doughty" <in*****@email.com> wrote in message
news:Xn*****************************@199.45.49.11. ..
I'm not sure why you splitting the users control into 2 pieces, but
if your smyUserControl is know you can add it to the page. I've not
had a real issue with speed but none of the page are very graphic
intensive.

As far as elegance it all depends on your needs, I'm using a XML
Document to create part of the pages I generate, I have all the
data/controls stored in a database and I'm using a webservice to
retrueve the html page.(yes the webservice is slow on the intiall
load of the page but I like the fact I if I need to redeploy this
piece the users will more than likely never see a glith on the
system)

I'm also curious what are you using as the HTML editor?

James Doughty

Nov 19 '05 #20
<< I can't think of anything else>>

Thanks!
"James Doughty" <in*****@email.com> wrote in message
news:Xn*****************************@199.45.49.11. ..
Sounds like your well on your way, I can't think of anything else.

Good luck,
James
"Guadala Harry" <GM**@NoSpam.net> wrote in
news:uG**************@TK2MSFTNGP09.phx.gbl:
<<I'm not sure why you splitting the users control into 2 pieces>>
Actually I have a number of user controls in play here, and none are
getting split, themselves. What IS getting split is some HTML text
(supplied by the user via a rich text editor) that gets injected into
one of the user controls; and it's getting split ONLY so I can insert
another user control in the middle of that HTML.
The end result of this is that the user can create some HTML content.
They can enter some special "flag text" that indicates where a content
rotator should go. The final result is that they get a content rotator
in the middle of their content - and they don't have to know how to
create the content rotator. All they have to do is know how to specify
the special "flag text" correctly and place it where they want it.
FWIW: That content rotator is contained within the user control that
I'm injecting into the middle of the HTML text.
Sample:
"<table><tr><td>{ContentRotatorHere}</td></tr></table>"
The user creates the above complete HTML string - which gets saved to
a database. This is a gross oversimplification of course. Then, when
it's time to display their content elsewhere in the app - I pull that
HTML string out of a database, split it into two strings - one before
"{ContentRotatorHere}" and the other for what comes after it; then I
insert the two "HTML strings" into a Placeholder control along with
the user control that contains the content rotator. I add the HTML via
two Literal controls, and add the content rotator's containing user
control between them in the Placeholder control. This all actually
works! It's a lot going on - but with a healthy dose of Caching
runtime performance is great.

<<I'm also curious what are you using as the HTML editor>>
A heavily customized implementation of CuteEditor which you can see at
www.CuteSoft.net

-GH
"James Doughty" <in*****@email.com> wrote in message
news:Xn*****************************@199.45.49.11. ..
I'm not sure why you splitting the users control into 2 pieces, but
if your smyUserControl is know you can add it to the page. I've not
had a real issue with speed but none of the page are very graphic
intensive.

As far as elegance it all depends on your needs, I'm using a XML
Document to create part of the pages I generate, I have all the
data/controls stored in a database and I'm using a webservice to
retrueve the html page.(yes the webservice is slow on the intiall
load of the page but I like the fact I if I need to redeploy this
piece the users will more than likely never see a glith on the
system)

I'm also curious what are you using as the HTML editor?

James Doughty

Nov 19 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
11024
by: Rick Spiewak | last post by:
I need to generate a "buy" button as part of an ASP.NET page - this consists of a small HTML form with hidden fields, conforming to the requirements of a merchant credit card processor. PayPal is...
4
3065
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a...
7
3619
by: | last post by:
I am having trouble figuring out to call a database INSERT procedure from a simple submit form. It appears I should use the onclick event to trigger the procedure called BUT when I do this I...
0
421
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
7
2971
by: Shimon Sim | last post by:
I have a custom composite control I have following property
8
3097
by: Brendan Reynolds | last post by:
I'm trying to integrate SQL Server Reporting Services reports into an ASP.NET app (SRS 2000, ASP.NET 1.1). I know how to do this using direct URL addressing, but this exposes in the query string...
5
4066
by: Andrew | last post by:
Hi, friends, In ASP, we use obj = CreateObject("com.dll") obj.GetHTMLText(inVal, outHTMLTxt1, outHTMLTxt2) to get different HTML strings based on input values. Then, we insert them into...
2
4898
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
4
9044
by: John Kotuby | last post by:
Hi all, I am using a Repeater in conjunction with a SQLDatasource and SQL Server. One of the controls in the repeater is a HyperlLink as follows: <asp:HyperLink...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.