By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,781 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,781 IT Pros & Developers. It's quick & easy.

dynamic link creatation

P: n/a
Hi-
I am interested in creating links within my pages dynamically as they are
requested. For example, someone requests a page, my web app. would parse
the generated *.aspx HTML and add links to words or phrases that my app
deems appropriate.

I have tried to think of the best way to do this, the most efficient way.
It doesn't have to be done each time it's requested, I would actually prefer
if it were cached one it is done. I am trying to avoid maintaining upwards
of 100 links per page and would like to automate if possible.

I am interested in suggestions. All I have come up with is to use the Page
class to access the rendered HTML and process and modify that string. Is
this a good way to go about this?

Thank You,
Steve
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I would not parse the html (raw) after it was created,

Instead once the page has been rendered (use the render event),

Then loop through all controls on the page, if it is a literal control
(i.e. just text) you can then pattern match it (possibly Regex) to see
if you need to replace the text with links.

Replace any text with links (dynamically create the controls),

Finally have a look at output caching, this allows the HTML to be
cached so that you don't need to create it each time,

Hope this helps

Nov 19 '05 #2

P: n/a
Two suggestions:

You can use the Filter property of the HttpResponse object. This is a
Stream derived object that you can use to manipulate the outgoing response.

http://aspalliance.com/71

You can place all your "custom links" into a UserControl and set the
OutputCache on it, so it will only have to be calculated once.

bill


"Steve" <ss*@sss.com> wrote in message
news:eN**************@TK2MSFTNGP09.phx.gbl...
Hi-
I am interested in creating links within my pages dynamically as they are
requested. For example, someone requests a page, my web app. would parse
the generated *.aspx HTML and add links to words or phrases that my app
deems appropriate.

I have tried to think of the best way to do this, the most efficient way.
It doesn't have to be done each time it's requested, I would actually prefer if it were cached one it is done. I am trying to avoid maintaining upwards of 100 links per page and would like to automate if possible.

I am interested in suggestions. All I have come up with is to use the Page class to access the rendered HTML and process and modify that string. Is
this a good way to go about this?

Thank You,
Steve

Nov 19 '05 #3

P: n/a
That is an interesting way of handling this, but I am not sure I agree. You
have two suggestions thus far and I will add a third (a bit rough, perhaps,
as I did not really do any design work):

I would consider making the entire page creation dynamic rather than attempt
to loop through the "rendered" HTML. One option then is to have a program run
through each bit of output (stored in a database most likely) and add the
tags you need. The new string can be stored in another column (database) or
cached in the ASP.NET caching mechanism (done on the fly or ahead of time).

Gareth's suggestion: Loop through controls. This is possible, but it can be
problematic if you do not follow Microsoft best practices (ie, have a lot of
hybrid HTML/ASP.NET).

William's suggestion: Filter ASP.NET traffic. I like the idea of using Http
handlers or filters, etc. to control output. You can cache here, as well. The
benefit is you do not have to write the handler more than once to have every
page with links added. The only negative is the coding is a bit more complex
with you use these objects. It is worth it, however.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Steve" wrote:
Hi-
I am interested in creating links within my pages dynamically as they are
requested. For example, someone requests a page, my web app. would parse
the generated *.aspx HTML and add links to words or phrases that my app
deems appropriate.

I have tried to think of the best way to do this, the most efficient way.
It doesn't have to be done each time it's requested, I would actually prefer
if it were cached one it is done. I am trying to avoid maintaining upwards
of 100 links per page and would like to automate if possible.

I am interested in suggestions. All I have come up with is to use the Page
class to access the rendered HTML and process and modify that string. Is
this a good way to go about this?

Thank You,
Steve

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.