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

Add control do page. What is going wrong here?

Hello,

On my Page_Init event I have the following:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles MyBase.Init

Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)

End Sub

And pContainer_Init is given by:

Private Sub pContainer_Init(ByVal sender As Object, ByVal e As
EventArgs)

' Find pContainer in page
Dim pContainer As Panel = CType(Page.FindControl("pContainer"),
Panel)

' Define pContainer properties
If Not (pContainer Is Nothing) Then
With pContainer
.CssClass = "pContainer"
.Text = "pContainer"
.Width = Unit.Pixel(760)
End With
Else
Response.Write("No Container/")
End If

End Sub

When I run it I can't see the panel. I get the string "NoContainer/"
as it wasn't found.

What am I doing wrong here?

Thanks,

Miguel

Nov 7 '06 #1
1 980
you don't give the panel a ID when you create it, so there is no way to find
it by ID (name).

-- bruce(sqlwork.com)
"shapper" <md*****@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hello,

On my Page_Init event I have the following:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles MyBase.Init

Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)

End Sub

And pContainer_Init is given by:

Private Sub pContainer_Init(ByVal sender As Object, ByVal e As
EventArgs)

' Find pContainer in page
Dim pContainer As Panel = CType(Page.FindControl("pContainer"),
Panel)

' Define pContainer properties
If Not (pContainer Is Nothing) Then
With pContainer
.CssClass = "pContainer"
.Text = "pContainer"
.Width = Unit.Pixel(760)
End With
Else
Response.Write("No Container/")
End If

End Sub

When I run it I can't see the panel. I get the string "NoContainer/"
as it wasn't found.

What am I doing wrong here?

Thanks,

Miguel

Nov 7 '06 #2

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

Similar topics

7
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control...
0
by: Jason Chancellor | last post by:
Fairly new to asp.net so I'm sure what I'm doing wrong is silly... I have created a user control which contains its own buttons, textboxes, etc... and handles its own events. If I add just one...
12
by: Tom wilson | last post by:
This is the same topic as the thread above, "Dealing with the Back button". I'm getting nowhere. The closest I've come is a sample left for me: <%@ Page Language="vb" %> <!DOCTYPE HTML PUBLIC...
9
by: TCORDON | last post by:
I have a user control that contains 2 image buttons, when you click one of them, both must change the image source, the thing is that the first time you click any one of them the page appears to do...
6
by: evandelagrammaticas | last post by:
Hi all. I have spent the better part of a day scouring the newsgroups and I am sure that I must have come across the solution a number of times - but I am still a real newbie at asp.net so please...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
12
by: raghav | last post by:
Hi I am working on ASP.NET 2.0. I am developing a website using Wizard control. Based on number of steps added, next, previous, finish buttons generate automatically. After running the...
17
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I get the value of a form control? -----------------------------------------------------------------------...
7
by: Andy B | last post by:
I have a class I am creating for data access. I need to access controls from inside the class that are on a particular page. How do I do this? or is creating an instance of the page class and using...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: 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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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.