Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Error: Panel is not declared

Posted on 2007-08-08
19
Medium Priority
?
956 Views
Last Modified: 2013-11-26
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
0
Comment
Question by:John Account
  • 8
  • 6
  • 5
19 Comments
 
LVL 37

Expert Comment

by:samtran0331
ID: 19656996
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

0
 

Author Comment

by:John Account
ID: 19657088
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'.
0
 
LVL 18

Expert Comment

by:DropZone
ID: 19657090
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:John Account
ID: 19657264
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
0
 

Author Comment

by:John Account
ID: 19657282
By the way, Drop Zone, you skydive? This is me enjoying a fun skydive: http://video.google.ca/videoplay?docid=5315858865168306265&hl=en-CA
0
 
LVL 18

Accepted Solution

by:
DropZone earned 1000 total points
ID: 19657425
Is the 'panGoogleVid' panel within another container? if so, you won't be able to access it directly; you'll have to use FindControl to get it from the panel.  For example, supposing that it is within PanelFoo:

<asp:Panel id="PanelFoo" runat="server">
     <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>
</asp:Panel>

Then your code would need to be:

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim VidPanel As Panel

        mySrc = ""
        Button2.Visible = False
        VideoStoppedMsg.Visible = True
        VidSermonsTitle.Visible = True

        ' Find the panGoogleVid panel
        VidPanel = PanelFoo.FindControl("panGoogleVid")
        If (VidPanel <> Nothing) Then
            VidPanel.Visible = False
        Else
            ' Raise an exception or something!
        End
    End Sub


You can avoid having to do this FindControl code every time you want to access it by creating a property to access the panGoogleVid panel encapsulating the code.

    -dZ.
0
 
LVL 18

Expert Comment

by:DropZone
ID: 19657428
I forgot to mention that, yes, I used to skydive -- a long, long time ago. :)

    -dZ.
0
 
LVL 37

Assisted Solution

by:samtran0331
samtran0331 earned 1000 total points
ID: 19657445
since the panel is on your aspx page you are not using an instantiated panel...

when you added the panel to your page, Visual Studio should have added a line that reads:
Protected WithEvents panGoogleVid As Global.System.Web.UI.Controls.Panel

this would be in the pagename.aspx.designer.vb file

If that line exists and you are still getting an error that the control is not declared, I would recommend:
1. quick fix:
delete the panel, compile, re-add a new panel

2. Clear out your server cache
a. close VS
b. restart IIS (from a command prompt, type in:  iisreset)
c. go to:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

d. delete everything in there
e. re-test
f. if it still fails, now do #1 again

0
 
LVL 37

Expert Comment

by:samtran0331
ID: 19657553
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>
0
 
LVL 18

Expert Comment

by:DropZone
ID: 19657623
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.
0
 

Author Comment

by:John Account
ID: 19657736
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.

0
 
LVL 18

Expert Comment

by:DropZone
ID: 19657795
Are you working on this page in the VS designer or from a different text editor?

    -dZ.
0
 

Author Comment

by:John Account
ID: 19657900
Working in Visual Studio 2005
0
 
LVL 37

Expert Comment

by:samtran0331
ID: 19657928
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.
0
 

Author Comment

by:John Account
ID: 19658006
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.
0
 
LVL 18

Expert Comment

by:DropZone
ID: 19658036
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.
0
 

Author Comment

by:John Account
ID: 19658199
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.
0
 
LVL 37

Expert Comment

by:samtran0331
ID: 19658789
did you clear the "server cache" folder?
0
 

Author Comment

by:John Account
ID: 19665754
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/
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

581 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