Avatar of OliShim
OliShim

asked on 

UpdatePanel controls not accessible in MasterPage programmatically

Hello,

I cannot get access to an UpdatePanel's contol,  a Label, within a Masterpage using ASP.NET AJAX and VB.NET.   This code in inside the Page_Load event BTW.  Can anyone help me on this?   Here is the code:


        Dim cph As ContentPlaceHolder = CType(Master.FindControl("contentplaceholder1"), ContentPlaceHolder)
        Dim upp As Microsoft.Web.UI.UpdatePanel = CType(cph.FindControl("UpdatePanel1"), Microsoft.Web.UI.UpdatePanel)

        Dim myLabel3 As Label = CType(upp.ContentTemplateContainer.FindControl("Label3"), Label)

        Response.Write(myLabel3.ID)  'this errors out
        Response.End()
ASP.NETAJAXVisual Basic.NET

Avatar of undefined
Last Comment
OliShim
Avatar of JonMny
JonMny

is this control being created dynamically? if so you will want to make sure that you create it in the init event.

if it's  on the masterpage at design time, try adding the @mastertype directive to the child page and you will be able to access it without the findcontrol.
ex master.Label3



Avatar of ororiole
ororiole
Flag of United States of America image

1. Are you sure upp is being set? Maybe its not finding that.
2. Your findcontrol for label3 will work, if in fact, label3 is there. Are you sure you have a label3? Is label3 inside anything else?
Avatar of OliShim
OliShim

ASKER

Hello,
Thanks for your replies.  The control is not being created dynamically.  It is declared on the aspx script page.  The UpdatePanel variable, upp, is being set and found.  Label3 is inside a HTML table.  Here is the script code:


     
   
   
    Submit
    Clear Search
   
   
       
         
       
         
       
         
       
       
   

Thanks again!  I will keep trying!
ASKER CERTIFIED SOLUTION
Avatar of JonMny
JonMny

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of OliShim
OliShim

ASKER

error message:  Object reference not set to an instance of an object.

I just got it to finally work though! very perturbed by this as I don't remember anything different in the code the last few days when it DIDN'T work.. hugh..
Thanks for the help though!  I will be back shortly w/ a Gridview SQL update issue.
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo