Link to home
Start Free TrialLog in
Avatar of John Account
John Account

asked on

Error: Panel is not declared

I'm trying to publish/compile my asp.net 2.0 VB website, and got the following error:
C:\MyWebSite\Videos.aspx.vb(11,0): error BC30451: Name 'panGoogleVid' is not declared.
How do I fix this error?

panGoogleVid is aPanel that, based on events occuring on the page, is either visible or not visible; like this, for instance...
    Protected Sub Menu3_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles Menu3.MenuItemClick
        Button2.Visible = True
        mySrc = Menu3.SelectedValue
        If mySrc = "GoogleVideo" Then
            mySrc = ""
            Select Case (Menu3.SelectedItem.ToolTip)
                Case ("Dealing Drastically With Our Sinful Nature: 35 min 21 sec (Recorded: 29 July 07)")
                    myGoogle = "http://video.google.com/googleplayer.swf?docId=-3758984925195200639&hl=en-CA"
                    panGoogleVid.Visible = True
            End Select
            Me.VideoStoppedMsg.Visible = True
        Else
            myGoogle = ""
            VideoStoppedMsg.Visible = False
            VidSermonsTitle.Visible = False
            panGoogleVid.Visible = False
        End If
    End Sub
Avatar of samtran0331
samtran0331
Flag of United States of America image

You're using Visual Studio right?
If yes, right-click on the word "panGoogleVid" in any part of that code you posted and then choose "Go to Definition"....it should take you to the designer file with a line like:
Protected withevents panGoogleVid as system.web.ui.controls.panel

Avatar of John Account
John Account

ASKER

samtran0331, Okay, hmmmmnnn...I right-clicked it, but the cursor went no where--just to a <br /> point in the page. So then I selected to 'Find All References' instead, but then when I click on "Protected withevents panGoogleVid as system.web.ui.controls.panel" to go to definitions, it says 'The Definition Of The Object Is Hidden'.
Are you instantiating the panGoogleVid object dynamically or at design time in the page template?  If the former, make sure that it has been initialized prior to the Click event.  If the latter, then make sure that the IDE inserted the appropriate reference in your code when you added the control to the page.

    -dZ.
You know, DropZone, I really don't know. I guess that's the problem there.  These blocks of code below are the only references to the panGoogleVid object. What am I missing?

---ASPX PAGE------
 <asp:Panel ID="panGoogleVid" runat="server" Height="267px" Style="z-index: 103; left: 20px;
            position: absolute; top: 26px" Width="330px" Visible="False">
            <div id="VideoOnGoogle" style="z-index: 103; left: 0px; width: 291px; position: absolute;
                top: 0px; height: 240px">
            <embed style="width:320px; height:266px;" id="VideoPlayback" type="application/x-shockwave-flash" src=<%=myGoogle%> FlashVars="autoPlay=true"> </embed>              
            </div>
        </asp:Panel>

----CODE BEHIND-------
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        mySrc = ""
        Button2.Visible = False
        VideoStoppedMsg.Visible = True
        VidSermonsTitle.Visible = True
        panGoogleVid.Visible = False
    End Sub

    Protected Sub Menu3_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles Menu3.MenuItemClick
        Button2.Visible = True
        mySrc = Menu3.SelectedValue
        If mySrc = "GoogleVideo" Then
            mySrc = ""
            Select Case (Menu3.SelectedItem.ToolTip)
                Case ("Dealing Drastically With Our Sinful Nature: 35 min 21 sec (Recorded: 29 July 07)")
                    myGoogle = "http://video.google.com/googleplayer.swf?docId=-3758984925195200639&hl=en-CA"
                    panGoogleVid.Visible = True
            End Select
            Me.VideoStoppedMsg.Visible = True
        Else
            myGoogle = ""
            VideoStoppedMsg.Visible = False
            VidSermonsTitle.Visible = False
            panGoogleVid.Visible = False
        End If
    End Sub
End Class
By the way, Drop Zone, you skydive? This is me enjoying a fun skydive: http://video.google.ca/videoplay?docid=5315858865168306265&hl=en-CA
ASKER CERTIFIED SOLUTION
Avatar of DropZone
DropZone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I forgot to mention that, yes, I used to skydive -- a long, long time ago. :)

    -dZ.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Panels within panels or contentplaceholders will work fine without using the "findcontrol" technique...it's usually when a control is nested inside a data control like a gridview or formview that you need to use findcontrol to get at the nested control...

this page works fine with panel2 and panel3 nested inside panel1

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Me.Panel2.Visible = False
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Me.Panel3.Visible = False
    End Sub

    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Me.Panel2.Visible = True
        Me.Panel3.Visible = True
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Panel ID="Panel1" runat="server">
                Panel 1
                <asp:Panel ID="Panel2" runat="server" Height="50px" Width="125px">
                    Panel 2</asp:Panel>
                <asp:Panel ID="Panel3" runat="server" Height="50px" Width="125px">
                    Panel 3</asp:Panel>
            </asp:Panel>
            <br />
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Hide panel 2" />
            <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Hide panel 3" />
            <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Show 2 and 3" />
        </div>
    </form>
</body>
</html>
Yes, but we still don't know if the control is contained within a templated control; he only posted an excerpt of the ASPX page where the panGoogleVid is declared, not the entire page.

JohnLucio, is the panGoogleVid panel contain within another control, or more specific, within a templated control?

     -dZ.
Sorry for taking so long to get back, guys. Been very busy with this. Anyways...no, it is not nested within another control. And I can't find this block anywhere: Protected WithEvents panGoogleVid As Global.System.Web.UI.Controls.Panel

So I deleted the panel and added a new panel as you suggested, samtran0331; but still getitng same error; but I guess I need to clear my cache.

Oh...btw, this file pagename.aspx.designer.vb does not exist, where pagename represents the actual name being used.

Should I show all the code in the aspx and code behind pages in here?--it's a lot.

Are you working on this page in the VS designer or from a different text editor?

    -dZ.
Working in Visual Studio 2005
dZ:"Yes, but we still don't know if the control is contained within a templated control; he only posted an excerpt of the ASPX page where the panGoogleVid is declared, not the entire page."

True, but I wanted to clarify that your example at post ID:19657425 with the nested panels and using findcontrol was (imho) not the right way to go.
Plus, if it was templated control issue, you'd more likely get the "Object reference not set to an instance of an object" error.

JohnLucio:"this file pagename.aspx.designer.vb does not exist"

That tells me you're using a VS2005 "Web Site Project" and not a migrated VS2003 project or a "Web Application Project"...
With a Web Site Project, the designer.vb file is created/compiled dynamically and the developer never sees or modifies the file....but something did get corrupted somehow...

I would try giving the machine a reboot and clearing the asp.net cache before doing anything else (like opening VS or testing the page)

If it still errors, another thing to try is to actually paste into your codebehind page:
Protected WithEvents panGoogleVid As System.Web.UI.Controls.Panel

Put it right under the "Inherits..." line of the codebehind file.
Yeah, that's what I was thinking--I don't recall every seen pagename.aspx.designer.vb  in a Web Site Project in VS2005. Okay, samtran0331. Thanks. I"ll do that now.
samtran0331:  Sorry, you are right and I stand corrected.  Although I am experienced with the .NET framework, I have never had the opportunity to use Visual Studio.NET, and so I'm not familiar with its idiosyncracies.  I use Delphi.NET which has its own set of issues.

   -dZ.
Okay, talk about issues & idiosyncracies--now this is really weird, guys!----
I got frustrated, created another folder on my computer, then created another project and saved it in that folder. Then copied Videos.aspx & Videos.aspx.vb into that new folder, and refreshed my new project. Now...hmmmmnnnn...this new project compiles without any problem what so ever! Except this project has only those two files--which leads me to believe that the problem isn't in either of these files. Hmmmmnnnnn.
did you clear the "server cache" folder?
Gentlemen, thank you very much. I've applied everything you taught me, and finally got it working. After all was said and done, in the end, what I had to do was break that particular site down into 3 projects:
1. All the Root Pages
2. Ministry Pages
3. Video Sermons Page

I don't know why I had to put it into 3 projects, I just know that's the only way I could get everything to publish, and .dll files for the site created.

Again, thank you very much for your help. If you wanna see the site, it's right here: http://www.fountaingate.org/