473,387 Members | 1,431 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,387 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 5737
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: TB | last post by:
Hi All: I have this page where a rows / cells are programmatically added to to table by pushing a button. The rows contain a textbox and a associated button. What I want to is to be able to...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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,...

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.