p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 3.5 Basics (http://p2p.wrox.com/forumdisplay.php?f=351)
-   -   Chapter 8 - Implementing ViewState Properties (http://p2p.wrox.com/showthread.php?t=71094)

janla2112 October 18th, 2008 01:13 PM

Chapter 8 - Implementing ViewState Properties
 
Hi,
I have learned a lot from this book and expect to re-read it many times in the future to re-learn things as I need them. I have been able to Debug all of the mistakes I have made and even found one in the book that was incorrect after Microsoft went to SP1. I would have to go back and find it, but it had to do with getting rid of all the closing tags down to one. I will get back to you on that one.

Anyways. I am trying to run the exercise "Implementing the NavigateUrl Property on page 283, however I run into the following Compilation Errors:

Error 1 C:\BegASPNET\Site\Controls\Banner.ascx.vb(21): error BC30451: Name 'lnkHorizontal' is not declared.

Error 2 C:\BegASPNET\Site\Controls\Banner.ascx.vb(21): error BC30451: Name 'lnkHorizontal' is not declared.


Error 3 C:\BegASPNET\Site\Controls\Banner.ascx.vb(21): error BC30451: Name 'lnkHorizontal' is not declared.

Error 4 C:\BegASPNET\Site\Controls\Banner.ascx.vb(21): error BC30451: Name 'lnkHorizontal' is not declared.

Error 5 'NavigateUrl' is not a member of 'ASP.controls_banner_ascx'. C:\BegASPNET\Site\About\AboutUs.aspx.vb 7 7 C:\BegASPNET\Site
Error 6 Name 'lnkHorizontal' is not declared. C:\BegASPNET\Site\Controls\Banner.ascx.vb 21 9 C:\BegASPNET\SiteError 7 Name 'NavigateUrl' is not declared. C:\BegASPNET\Site\Controls\Banner.ascx.vb 21 30 C:\BegASPNET\SiteError 8 Name 'lnkVertical' is not declared. C:\BegASPNET\Site\Controls\Banner.ascx.vb 24 9 C:\BegASPNET\SiteError 9 Name 'NavigateUrl' is not declared. C:\BegASPNET\Site\Controls\Banner.ascx.vb 24 28 C:\BegASPNET\Site
I believe I have done everything by the letter, but can't seem to get past this. I can't figure out where it should be declared if it isn't. I appreciate any help.

Thanks,

Jan

Imar October 18th, 2008 06:43 PM

Hi Jan,

Can you post the code for the user control; both the .ascx code and the code behind?

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.

janla2112 October 19th, 2008 09:35 AM

Hi Imar:
Here is the user control banner code:

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Banner.ascx.vb" Inherits="Controls_Banner" %>
<asp:Panel ID="pnlVertical" runat="server">
  <a href="http://p2p.wrox.com" target="_blank"> runat="server" id="lnkVertical">
  <asp:Image ID="Image1" runat="server" AlternateText="This is a simple banner"
          ImageUrl="~/Images/Banner120x240.gif" />
  </a>
</asp:Panel>
<asp:Panel ID="pnlHorizontal" runat="server">
  <a href="http://p2p.wrox.com" target="_blank"> runat="server" id="lnkHorizontal">
  <asp:Image ID="Image2" runat="server" AlternateText="This is a simple banner"
          ImageUrl="~/Images/Banner468X60.gif" />
  </a>
</asp:Panel>

and the code behind:

Partial Class Controls_Banner
    Inherits System.Web.UI.UserControl
  Private _displayDirection As direction = direction.Vertical

  Public Property DisplayDirection() As direction
    Get
      Return _displayDirection
    End Get
    Set(ByVal value As direction)
      _displayDirection = value
    End Set
  End Property

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    pnlHorizontal.Visible = False
    pnlVertical.Visible = False

    Select Case DisplayDirection
      Case direction.Horizontal
        lnkHorizontal.Href = NavigateUrl
      Case direction.Vertical
        pnlVertical.Visible = True
        lnkVertical.HRef = NavigateUrl
    End Select
  End Sub
End Class


I couldn't figure out what I did wrong.

Thanks for your help!

Jan

janla2112 October 21st, 2008 03:17 PM

I figured it out. I did not move a closing tag to the end of a line, when I was adding code to the page behind so Banner and Banner1 were not being recognized.:)

Jan

Imar October 21st, 2008 03:57 PM

Glad you figured it out, and sorry for not responding to your reply; somehow I completely overlooked your post (looks like I didn't get a notification).

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.


All times are GMT -4. The time now is 09:04 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.