2013-02-24 77 views
1

我有這個錯誤在我的vb.net剃鬚刀2代碼「對象變量或塊變量未設置」。 11錯誤在每個循環vb.net剃鬚刀2(ASP.NET網頁)

Line 9:  Dim i = 0 
    Line 10:   
    Line 11:  @For Each color In PageData("Colors") 
    Line 12:   @<p style="background-color:@color; font-family:@Page.Fonts(i)"> 
    Line 13:    This paragraph is @color 

線這是我的_PageStart.vbhtml代碼:

@Code 
     Layout = "~/Shared/_Layout1.vbhtml" 
     PageData("Colors") = {"LightCyan", "Gainsboro", "Chocolate"} 
    End Code 

這是我的default.vbhtml代碼:

@Code 
     Page.Title = "Level 1 Start page" 
     Layout = "~/Shared/_Layout2.vbhtml" 
    End Code 

    <h1>Testing _PageStart From Level 1</h1> 

    @Code 
     Dim i = 0 

     @For Each color In PageData("Colors") 
      @<p style="background-color:@color; font-family:@Page.Fonts(i)"> 
       This paragraph is @color 
      </p> 
      i += 1 
     Next 

    End Code 

    <p><a href="/Level1/Page">Click</a> to visit Level 1</p> 

回答

0

從你所示的代碼,你不會出現在您正在使用的書中的相關試用版的步驟10中已經初始化了Page.Fonts。這是一個VB版本:

Page.Fonts = {"Verdana", "Arial", "Courier New"}