473,320 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Generating HTML Client Objects Just Once

I want to create an ASP.NET class which generates some client-side HTML
objects on a page with the following rules:

1. Only generate these objects from the class if they haven't already been
inserted by another instantiation of this class. So if the obejcts have
already been inserted, determine that this is the case and don't do it again.

2. Insert these HTML objects at the very end of the <BODYof the page,
preferably without the <BODYhaving been set as a runat="server".

So there are a few things I don't understand:

a) How do I check a page I'm processing on the server to see if HTML
elements have been dumped into the page with certain IDs, etc?

b) How do I indert these elements at the very end of the <BODYelement?

Alex
Jul 9 '06 #1
4 1176
Add a Panel control just before </bodytag and add controls to the Panel
controls collection.

Panel1.Controls.Add(ControlName)

You can then search to see if the controls have been added to the panel when
you are rendering other controls that would fill the Panel with the same
control.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
"Alex Maghen" <Al********@newsgroup.nospamwrote in message
news:0F**********************************@microsof t.com...
>I want to create an ASP.NET class which generates some client-side HTML
objects on a page with the following rules:

1. Only generate these objects from the class if they haven't already been
inserted by another instantiation of this class. So if the obejcts have
already been inserted, determine that this is the case and don't do it
again.

2. Insert these HTML objects at the very end of the <BODYof the page,
preferably without the <BODYhaving been set as a runat="server".

So there are a few things I don't understand:

a) How do I check a page I'm processing on the server to see if HTML
elements have been dumped into the page with certain IDs, etc?

b) How do I indert these elements at the very end of the <BODYelement?

Alex

Jul 9 '06 #2
I dig that. Except one thing: I don't want to have to know ANYTHING about the
page into which I'm trying to dump this stuff. Meaning, I won't be able to be
sure that the Panel you're suggesting actually exists on the page. Pretty
much the only thing I want to insist upon is that the basic <body></bodybe
present. Any way I can do this?

Thanks!

Alex
"Cowboy (Gregory A. Beamer)" wrote:
Add a Panel control just before </bodytag and add controls to the Panel
controls collection.

Panel1.Controls.Add(ControlName)

You can then search to see if the controls have been added to the panel when
you are rendering other controls that would fill the Panel with the same
control.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
"Alex Maghen" <Al********@newsgroup.nospamwrote in message
news:0F**********************************@microsof t.com...
I want to create an ASP.NET class which generates some client-side HTML
objects on a page with the following rules:

1. Only generate these objects from the class if they haven't already been
inserted by another instantiation of this class. So if the obejcts have
already been inserted, determine that this is the case and don't do it
again.

2. Insert these HTML objects at the very end of the <BODYof the page,
preferably without the <BODYhaving been set as a runat="server".

So there are a few things I don't understand:

a) How do I check a page I'm processing on the server to see if HTML
elements have been dumped into the page with certain IDs, etc?

b) How do I indert these elements at the very end of the <BODYelement?

Alex


Jul 10 '06 #3
Hi Alex,

Thank you for your post.

Based on my understanding, your question is how to insert certain content
into the generated html source. If I've misunderstood anything, please feel
free to post here.

I think you can override the Render method of Page class to directly change
the generated html source:

protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
HtmlTextWriter tw = new HtmlTextWriter(new StringWriter(sb));
base.Render(tw);
sb.Replace("</body>", "<a href=\"#\">Hello</a></body>");
writer.Write(sb.ToString());
}

Above sample code is using a simple replacement and not checking if the
replacement is already done. But you can use Regular Expression to do that
easily.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 10 '06 #4
I want to create an ASP.NET class which generates some client-side HTML
objects on a page with the following rules:

1. Only generate these objects from the class if they haven't already been
inserted by another instantiation of this class. So if the obejcts have
already been inserted, determine that this is the case and don't do it again.

2. Insert these HTML objects at the very end of the <BODYof the page,
preferably without the <BODYhaving been set as a runat="server".

So there are a few things I don't understand:

a) How do I check a page I'm processing on the server to see if HTML
elements have been dumped into the page with certain IDs, etc?

b) How do I indert these elements at the very end of the <BODYelement?

Alex
Maybe you can use the RegisterStartupScript method for this. It's
designed to insert script blocks (at the end of the html), but as you
are required to add the surrounding <scripttags, maybe plain html
will work as well.
This method requires two parameters. The second is the block of code to
insert, and the first is a "key". You can use IsStartupScriptRegistered
to find out is there is already a block with that key (if there is, you
don't want to insert it again).

Hans Kesting
Jul 10 '06 #5

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

Similar topics

17
by: flupke | last post by:
Hi, i create my GUIs mainly via wxGlade. However when you start of to program and want to do some rearranging to the gui, wxglade overwrites your file and you've got to put your own code back...
6
by: Vanitha | last post by:
Hi All, I am developing a Web based application for an embedded target, using BOA webserver. I need to return some values to the HTML client. I am using CGI-C to extract the values sent by...
16
by: Philippe C. Martin | last post by:
Hi, I am trying to change the data in a form field from python. The following code does not crash but has no effect as if "form" is just a copy of the original html form. Must I recreate the...
3
by: mca | last post by:
Hi everyone, I'm new to asp.net and i have a question about separating the html code from the programming code. i have an unknown numbers of entries in my table. I want to make a hyperlink...
5
by: Yossarian | last post by:
I have a handheld running CE .NET 4.2 and I am using c# with framework 1.1 to develop a solution for syncing data that is on the handheld with the local pc. Our handheld cradles only support...
6
by: Lloyd Sheen | last post by:
Perhaps I have missed something but what I would like to do is have a more "controlled" method of generating HTML from a web service. I can create items using HtmlTable, HtmlTableRow, and...
4
by: chris.lyon | last post by:
I'm trying to generate visual python objects from django objects and therefore have objects called 'Ring' and 'Cylinder' as django objects and I want to create objects of those names in visual. I...
11
by: Faisal Vali | last post by:
Are there any guidelines people use that help them decide when it is better to dynamically generate all html elements using javascript versus actually writing some html and using it as scaffolding?...
0
by: Bill E. | last post by:
I will be creating an application using MS Access as a client to SQL Server 2005. Each user will have the client installed on his/her machine. Some users will be attached to the local network...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.