473,786 Members | 2,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1193
Add a Panel control just before </bodytag and add controls to the Panel
controls collection.

Panel1.Controls .Add(ControlNam e)

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********@new sgroup.nospamwr ote in message
news:0F******** *************** ***********@mic rosoft.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(ControlNam e)

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********@new sgroup.nospamwr ote in message
news:0F******** *************** ***********@mic rosoft.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(HtmlText Writer writer)
{
StringBuilder sb = new StringBuilder() ;
HtmlTextWriter tw = new HtmlTextWriter( new StringWriter(sb ));
base.Render(tw) ;
sb.Replace("</body>", "<a href=\"#\">Hell o</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 RegisterStartup Script 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 IsStartupScript Registered
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
2140
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 in. I think i can work around that (at least a bit) by making a second file that imports the gui generated by wxglade and make classes that extend the original ones. For instance i could have a class MainForm that extends the wxFrame
6
2265
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 the client from the server. I dont want to generate the entire HTML page each time from the server.'cos i need to refresh the status less than a second..
16
2926
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 form order to do that ? My point is for the client to be able to re-read the modified data.
3
1525
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 for every entry in my table. So i query the database and get for example 3 entries back. So in a while loop i can make 3 hyperlinks with response.write(.......) etc.
5
3445
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 network connections, no usb or serial, so i have to use networking to get the data transfered. Here's the problem. I have the server accepting connections fine, but i'm a little confused how to actually send the server data, and then how the...
6
1552
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 HtmlTableCell but is there a quick method once the table has been built to get the HTML, put it in a string for return the browser call for the web service? I notice that HtmlTable does not support InnerHtml so that is not doable. Ideas??
4
1286
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 can cludge it in varius ways by using dir and lots of if lookups but is there a way of doing this that allows the name to generate a visual object of the appropriate name or fail nicely if the visual object doesn't exist?
11
2736
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? I have been using the extjs framework ( I haven't see this library critiqued much on this forum - unlike prototype, jquery and dojo which the regulars here tend to eviscerate - unless i've missed some threads, which is quite possible) and it...
0
1653
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 where the SQL Server resides. Others will access the network via VPN. I was thinking of using an MDW workgroup file located on a network server to control access to various user interface elements (i.e., forms, reports) using defined groups. In...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8989
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5397
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.