Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I make dynamically added controls visible inside a panel control?

Posted on 2004-08-11
12
Medium Priority
?
517 Views
Last Modified: 2008-03-17
Hello again!

I am trying to add controls dynamically, link buttons and images.  The link buttons require a container of some sort since they must appear between the form tags.  Well the controls appear to be added just fine, but they are not visible.  The panels visible property is set to True.

How do I make the dynamically added controls visible?  The code is below.


<FORM>
<asp:Panel id="Panel1" style="Z-INDEX: 118; LEFT: 8px; POSITION: absolute; TOP: 552px" runat="server"
                        Height="144px" Width="520px" BackColor="Transparent"></asp:Panel>

</FORM>

                    cImageCon.Height = System.Web.UI.WebControls.Unit.Pixel(86)
                    cImageCon.Width = System.Web.UI.WebControls.Unit.Pixel(119)
                    cImageCon.Style("LEFT") = System.Web.UI.WebControls.Unit.Pixel(8).ToString
                    cImageCon.Style("POSITION") = "absolute"
                    cImageCon.Style("TOP") = System.Web.UI.WebControls.Unit.Pixel(lTop).ToString
                    cImageCon.Visible = True
                    cImageCon.ImageUrl = ibAdPic.ImageUrl
                    cLink.Height = System.Web.UI.WebControls.Unit.Pixel(25)
                    cLink.Width = System.Web.UI.WebControls.Unit.Pixel(56)

                    cLink.Style("Font-Bold") = "True"
                    cLink.Style("Font-Size") = "X-Small"
                    cLink.Style("Font-Names") = "Arial"
                    cLink.Style("runat") = "server"
                    cLink.Style("LEFT") = System.Web.UI.WebControls.Unit.Pixel(8).ToString
                    Dim LabelTop As Long = lTop
                    LabelTop = LabelTop + 100
                    cLink.Style("TOP") = System.Web.UI.WebControls.Unit.Pixel(LabelTop).ToString
                    cLink.Visible = True
0
Comment
Question by:bczingo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 7

Expert Comment

by:mdamico
ID: 11773721
I don't see anywhere where you are adding the controls to the panel/

Panel1.Controls.Add(cImageCon)
Panel1.Controls.Add(cLink)
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11773741
how bout using find control to access the properties:

Dim myForm As Control = Page.FindControl("FormFrame1")
            myForm.myTextBox.Visible = True

Regards,

Aeros
0
 
LVL 3

Author Comment

by:bczingo
ID: 11773907
Sorry.  Copy Paste error!

Panel1.Controls.Add(cLink)
Panel1.Controls.Add(cImageCon)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Expert Comment

by:Rodney Helsens
ID: 11774159
When you say the controls appear to be added just fine, I assume you have "viewed source" on the html and seen the controls there?

Try adding a simple control to the panel, does this show up? If so, there is a problem with the controls, where are you setting the text property of the link?

            Dim t As New TextBox()
            t.Text = "myTextBox"
            t.ID = "myTextBox"
            Panel1.Controls.Add(t)
0
 
LVL 3

Author Comment

by:bczingo
ID: 11774246
aerosaga,

I tried the find control method and it didn't reveal the control.
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11774334
then I suspect rodnex is correct in assuming that the controls are not being created correctly.
0
 
LVL 3

Author Comment

by:bczingo
ID: 11774335
Rodnex,

Yes They are there when I view source

<div id="Panel1" style="background-color:Transparent;height:144px;width:520px;Z-INDEX: 118; LEFT: 8px; POSITION: absolute; TOP: 552px">
      <img id="imgAdPhoto5" src="C:\Documents and Settings\Administrator\My Documents\My Pictures\Parts\0117.jpg" border="0" style="height:86px;width:119px;LEFT:8px;POSITION:absolute;TOP:596px;" />
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11774358
ok, so what happened when you attempted to find the controls?
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11774370
Heres a couple of alternate ways to try the same thing.

Dim x1 As myCustomControl = DirectCast(Me.FindControl("ReportMenu1"), myCustomControl)
                myPageLabel.text = x.MyCustomControl.Label.Text

Public ReadOnly Property GetMyLabelText() As String
 Get
   If Not Label1 Is Nothing Then Return Label1.TexT
 End Get
End Property


OR

Private _myParameter as String
Public Property myParameter() as String
  Get
    Return _myParameter
  End Get
  Set
    _myParameter = value
  End Set
End Property

Then in you aspx page:

Dim x1 As myCustomControl = DirectCast(Me.FindControl("ReportMenu1"), myCustomControl)
x1.myParameter = "XXXX"

0
 
LVL 9

Expert Comment

by:Rodney Helsens
ID: 11774463
put a border = 1 on that image, you will probably see that the image is being rendered, but you are referencing an absolute URL to the image..
0
 
LVL 9

Accepted Solution

by:
Rodney Helsens earned 2000 total points
ID: 11774555
ya know, after looking at that generated html code, there is a good chance that your problem is that the div may be hidden behind other divs, since you are setting its position to absolute, it shows up far left, towards the bottom of the screen with a zindex of 118.. take a long look at this..

0
 
LVL 1

Expert Comment

by:steve_mick972
ID: 11774900
interestingly when I ran ur code and first I could not see any controls and when accidentally scrolled through the page I saw that image and link button bottom of the page on the left hand side...
and I think rodnex might be right...  either u miss them seeing coz ur setting them as absolute r ur div tag might be causing the problem...

Steve
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question