473,401 Members | 2,139 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,401 software developers and data experts.

How to add programmatically a label into a content page?

Hi,

How to add programmatically a label into a content page?
I tried this but doesn't work:

Thanks
Phil
content page:
------------
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
</asp:Content>

code-behind:
-----------
dim lb as label
lb = New Label
Content1.controls.add("lb")
Mar 8 '07 #1
4 11206
xke
It won't work that way. Add another control inside
ContentPlaceHolder1, a table, a panel ...
Let's talk code:

YourPage.aspx:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:Panel ID="Panel1" runat="server"></asp:Panel>
</asp:Content>

YourPage.aspx.cs or YourPage.aspx.vb

On Page_Load

C#
Label lbl = new Label();
lbl.Text = "This is me!";
Panel1.Controls.Add(lbl);

VB.NET
dim lbl as new Label()
lbl.Text = "This is me!"
Panel1.Controls.Add(lbl)
Let me know if it's not working.

On Mar 8, 5:31 pm, "Phil" <uuvt...@fff.tywrote:
Hi,

How to add programmatically a label into a content page?
I tried this but doesn't work:

Thanks
Phil

content page:
------------
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
</asp:Content>

code-behind:
-----------
dim lb as label
lb = New Label
Content1.controls.add("lb")

Mar 9 '07 #2
Hi xke, thanks for replying ...

i get an error: Name 'Panel1' is not declared

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim lbl As New Label()
lbl.Text = "This is me!"
Panel1.Controls.Add(lbl)
End Sub
End Class
aspx:
----
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="addlabelcontent.aspx.vb"
Inherits="addlabelcontent" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
</asp:Panel>
</asp:Content>



"xke" <xk****@gmail.comschreef in bericht
news:11**********************@v33g2000cwv.googlegr oups.com...
It won't work that way. Add another control inside
ContentPlaceHolder1, a table, a panel ...
Let's talk code:

YourPage.aspx:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:Panel ID="Panel1" runat="server"></asp:Panel>
</asp:Content>

YourPage.aspx.cs or YourPage.aspx.vb

On Page_Load

C#
Label lbl = new Label();
lbl.Text = "This is me!";
Panel1.Controls.Add(lbl);

VB.NET
dim lbl as new Label()
lbl.Text = "This is me!"
Panel1.Controls.Add(lbl)
Let me know if it's not working.

On Mar 8, 5:31 pm, "Phil" <uuvt...@fff.tywrote:
>Hi,

How to add programmatically a label into a content page?
I tried this but doesn't work:

Thanks
Phil

content page:
------------
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
</asp:Content>

code-behind:
-----------
dim lb as label
lb = New Label
Content1.controls.add("lb")


Mar 9 '07 #3
Sorry, it works ... now !?!
"xke" <xk****@gmail.comschreef in bericht
news:11**********************@v33g2000cwv.googlegr oups.com...
It won't work that way. Add another control inside
ContentPlaceHolder1, a table, a panel ...
Let's talk code:

YourPage.aspx:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:Panel ID="Panel1" runat="server"></asp:Panel>
</asp:Content>

YourPage.aspx.cs or YourPage.aspx.vb

On Page_Load

C#
Label lbl = new Label();
lbl.Text = "This is me!";
Panel1.Controls.Add(lbl);

VB.NET
dim lbl as new Label()
lbl.Text = "This is me!"
Panel1.Controls.Add(lbl)
Let me know if it's not working.

On Mar 8, 5:31 pm, "Phil" <uuvt...@fff.tywrote:
>Hi,

How to add programmatically a label into a content page?
I tried this but doesn't work:

Thanks
Phil

content page:
------------
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
</asp:Content>

code-behind:
-----------
dim lb as label
lb = New Label
Content1.controls.add("lb")


Mar 9 '07 #4
xke
glad to hear it!
On Mar 9, 5:27 am, "Phil" <s...@ff.dfgwrote:
Sorry, it works ... now !?!

"xke" <xke...@gmail.comschreef in berichtnews:11**********************@v33g2000cwv.g ooglegroups.com...
It won't work that way. Add another control inside
ContentPlaceHolder1, a table, a panel ...
Let's talk code:
YourPage.aspx:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:Panel ID="Panel1" runat="server"></asp:Panel>
</asp:Content>
YourPage.aspx.cs or YourPage.aspx.vb
On Page_Load
C#
Label lbl = new Label();
lbl.Text = "This is me!";
Panel1.Controls.Add(lbl);
VB.NET
dim lbl as new Label()
lbl.Text = "This is me!"
Panel1.Controls.Add(lbl)
Let me know if it's not working.
On Mar 8, 5:31 pm, "Phil" <uuvt...@fff.tywrote:
Hi,
How to add programmatically a label into a content page?
I tried this but doesn't work:
Thanks
Phil
content page:
------------
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
</asp:Content>
code-behind:
-----------
dim lb as label
lb = New Label
Content1.controls.add("lb")- Hide quoted text -

- Show quoted text -

Mar 9 '07 #5

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

Similar topics

5
by: Carlo Marchesoni | last post by:
From an aspx page (A.aspx) I open another one (B.aspx - for table lookup). When the user selects an entry in B.aspx I would like to force a button's event in A.aspx to be fired. I guess the only...
4
by: Shaul Feldman | last post by:
Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmatically. I add CheckBoxList's Items on the fly, something...
2
by: Peter Rilling | last post by:
Below is some code that I do not know why it does not work. Okay, as you can see it is simple HTML with two ASP:Label controls. Each label has some code that basically gets a string that will be...
3
by: Paul | last post by:
I am using Visual Studio.net 2005 (and asp.net 2.0) Let's say that in a Web Project, I have created a (Dataset?) called SomeDataset.xsd. On it I have a TableAdapter called SomeTableTableAdapter...
0
by: Kevin Frey | last post by:
We have a data-centric application where all of the "layout" for each data centric page is to be codified (ie. it is expressed in C# code rather than being expressed declaratively). This...
3
by: Ken Fine | last post by:
I'm interested in programmatically manipulating groups of ASP.NET controls by type. Can someone suggest code for the following? Loop through, say, all label controls on a page, and assigning a...
4
by: Phil | last post by:
Hi, How to add programmatically a label into a content page? I tried this but doesn't work: Thanks Phil content page:
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
5
by: Nathan Sokalski | last post by:
I have css that would normally be placed in style tags in the header of the Master page that I want to add programmatically for a specific Web Content Form (the *.aspx page). How do I do this for a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.