473,652 Members | 3,123 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Generating live HTML server side controls from .Net classes

Hi folks,
I'm using ASP.net with Framework vs 1.1

I'm inheriting from a custom rolled master page class that is just that a
class that inherits from web.ui.page but it has no designer associated with
it. I want to generate some HTML inside the class and then that stuff will be
on every actual .aspx page that inherits from my master page class.

I want this to be output on every page (amongst other stuff)

<body id="intro">

<ul id="nav">
<li id="t-intro"><a href="Home.aspx ">Home</a></li>
<li id="t-about"><a href="Reports.a spx">Reports</a></li>
<li id="t-news"><a href="Search.as px.html">Search for a Record</a></li>
<li id="t-sponsors"><a href="admin.asp x">Admin</a></li>
</ul>

</body>
</html>

This is a navigation tab that I learned from Dan Cederholm's excellent book.
When it's CSSd it looks great
so my question is. What .net classes can be used to create these controls in
the masterPage class (litercontrol?, htmlControl?, htmlGenericCont rol)

I've had a go with no success and what's thwarting me is that whilst it's
easy to add say a <h1> heading this way, I have no idea how to add the outer
<ul> tag and then nest some <li> children inside it and then close the outer
tag...I can't seem to get any help from help
in a nutshell.
if I could get my master page class to generate some html inside it using
proper server activatable html controls, then every page I use will inherit
from my class masterPage and not web.ui.page and therefore it will have that
nav bar on it. (I've adapted this example from something I read in Esposito
magnum opus, so I'm not completely mad) the code has to be 'controls in
memory' (rather than just html strings) because I want to change certain
attributes of it on each page

any idea what code to write to generate that collection of HTML controls?
any answer would be greatly appreciated
Regards and thanks in advance,
CharlesA

Mar 10 '06 #1
2 2440
> Hi folks,
I'm using ASP.net with Framework vs 1.1

I'm inheriting from a custom rolled master page class that is just that a
class that inherits from web.ui.page but it has no designer associated with
it. I want to generate some HTML inside the class and then that stuff will be
on every actual .aspx page that inherits from my master page class.

I want this to be output on every page (amongst other stuff)

<body id="intro">

<ul id="nav">
<li id="t-intro"><a href="Home.aspx ">Home</a></li>
<li id="t-about"><a href="Reports.a spx">Reports</a></li>
<li id="t-news"><a href="Search.as px.html">Search for a Record</a></li>
<li id="t-sponsors"><a href="admin.asp x">Admin</a></li>
</ul>

</body>
</html>

This is a navigation tab that I learned from Dan Cederholm's excellent book.
When it's CSSd it looks great
so my question is. What .net classes can be used to create these controls in
the masterPage class (litercontrol?, htmlControl?, htmlGenericCont rol)

I've had a go with no success and what's thwarting me is that whilst it's
easy to add say a <h1> heading this way, I have no idea how to add the outer
<ul> tag and then nest some <li> children inside it and then close the outer
tag...I can't seem to get any help from help
in a nutshell.
if I could get my master page class to generate some html inside it using
proper server activatable html controls, then every page I use will inherit
from my class masterPage and not web.ui.page and therefore it will have that
nav bar on it. (I've adapted this example from something I read in Esposito
magnum opus, so I'm not completely mad) the code has to be 'controls in
memory' (rather than just html strings) because I want to change certain
attributes of it on each page

any idea what code to write to generate that collection of HTML controls?
any answer would be greatly appreciated
Regards and thanks in advance,
CharlesA


You can use a HtmlGenericCont rol. It has a constructor that lets you
specify a tag.

HtmlGenericCont rol ul = new HtmlGenericCont rol("ul");
ul.Attributes["id"] = "nav";
HtmlGenericCont rol li = new HtmlGenericCont rol("li");
li.Attributes["id"] = "t-intro";
li.InnerHtml = "<a href='Home.aspx '>Home</a>";
ul.Controls.Add (li);

and so on ...
Hans Kesting
Mar 10 '06 #2
A million thanks Hans

you've saved my day

I had some idea how to start an <ul> tag, but none on how to close it or
nest things inside it...
accomplished in your post with
ul.Controls.Add (li); I didn't know you could do that...
also the whole thing works a treat...

so thanks again
Warm regards,
CharlesA
Mar 10 '06 #3

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

Similar topics

2
8387
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
1
2519
by: Matthew Louden | last post by:
Personally, I am totally confused with the following control terms and usage and advantages of each one in ASP.NET web application. Here's what I know so far.. 1. HTML Client Control: understood by the client only. e.g. <input type="text" name="emp_name"> 2. HTML Server Control: understood by the server only. e.g. <input type="text" name="emp_name" runat="server"> 3. Web Server Control: understood by the server only. e.g. <asp:TextBox
7
3575
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the same way like regular input fields can. strForm = "<form name=""myForm"" runat=""server"">" & vbCrLf strForm += "<asp:button name=""myName"" .... runat=""server"" />" & vbCrLf
5
2085
by: Brian Kitt | last post by:
I have a C# application that builds dynamic HTML and renders it. Because it is rendered in this way, the input controls are not server controls. I write the entire page, which has a variable number of detail lines for an order. I want the user to be able to change values on these detail lines and hit an 'update' button. I know how to do this in Javascript, but I'd like to be able to inspect the controls that come back to my C# program...
4
2436
by: SAI | last post by:
Both have "TextBox" element and "Runat server". I don't understand the difference. Please advise. Thanks.
15
4750
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
5
3584
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact that for server control component , code is running on the server side. But if I take as example a Label. I place on a webform an HTM label control and a WebForm label control, I could see that properties are different for
1
1400
by: Andy Fish | last post by:
Hi, In my aspx web application, I am generating a list of items in a menu down the left-hand side. Different items in the list may have different controls in, and this is data-driven at runtime. At the moment I am using a custom template control similar to a repeater but with many different templates. However, It's a bit of a pain to work with and maintain. What I would like to do is generate the list of menu items using XSLT
2
1887
by: Ellie | last post by:
I am just starting to develop in asp.net and I have somewhat of a familiarity with asp 3.0. I am comfortable with asp 3.0 for my server side processing and javascript for client side. I also like the regular form, inputs, etc., in html. I seem to be having trouble with finding how to change the action for the asp.net form control to a different url and the action defaults to the same page that the form is on. It seems very confusing since...
0
8367
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
8279
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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
8703
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8589
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
7302
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...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
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 we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.