2010-11-23 20 views
0

私はコードを持っていますが、動作させることはできません。 私は名前空間とクラスとサブを持つ.vbサイトを持っています。 はその後、私のindex.aspxサイト上で私は2つのサイト このサブを呼び出すためにカント私のプロジェクトのルートにある、プロジェクトの名前がCALENDARWEEK名前空間VB.NetからクラスからSUBを呼び出す

である私のWeekController.vbは

Imports System 
Imports System.Web.UI.WebControls.Calendar 
Imports System.Globalization 

Namespace CalendarWeekController 
    Public Class WeekShow 

    Shared Sub Main() 
     ' Gets the Calendar instance associated with a CultureInfo. 
     Dim myCI As New CultureInfo("da-DK") 
     Dim myCal As Calendar = myCI.Calendar 

     ' Gets the DTFI properties required by GetWeekOfYear. 
     Dim myCWR As CalendarWeekRule = myCI.DateTimeFormat.CalendarWeekRule 
     Dim myFirstDOW As DayOfWeek = myCI.DateTimeFormat.FirstDayOfWeek 

     ' Displays the number of the current week relative to the beginning of the year. 
     Console.WriteLine("The CalendarWeekRule used for the en-US culture is {0}.", myCWR) 
     Console.WriteLine("The FirstDayOfWeek used for the en-US culture is {0}.", myFirstDOW) 
     Console.WriteLine("Therefore, the current week is Week {0} of the current year.", myCal.GetWeekOfYear(DateTime.Now, myCWR, myFirstDOW)) 

     ' Displays the total number of weeks in the current year. 
     Dim LastDay = New System.DateTime(DateTime.Now.Year, 12, 31) 
     Console.WriteLine("There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year) 
    End Sub 'Main 


End Class 

ですエンド名前空間

そして私のindex.aspxは、サイトを実行しているとき、私はこのエラーを取得

<%@ Import Namespace="CalendarWeekController" %> 
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
    <% 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 

     If Me.IsPostBack = False Then 
     Call WeekShow(Sub Main) 

     End If 
    End Sub 

%> 
    </div> 
    </form> 
</body> 
</html> 

です。 説明:この要求を処理するために必要なリソースの解析中にエラーが発生しました。以下の特定の解析エラーの詳細を確認し、ソースファイルを適切に変更してください。

パーサーエラーメッセージ: 'CalendarWeek.CalendarWeekController'を読み込めませんでした。

ソースエラー:

1行目:<% @ページ言語= "VB" AutoEventWireup属性= "false" を継承= "CalendarWeek.CalendarWeekController":インポート名前空間= "CalendarWeekController" %> ライン2 @ <% %> 行3: 行4:

答えて

0

Classname.Subnameと共有サブセットを呼び出す必要があります。あなたのケースでは :

WeekShow.Main() 
+0

こんにちは私はそれがほとんど機能しているコードを変更した場合、私は今、このエラーが出る: ステートメントは、メソッド本体内に表示することはできません。メソッドの終了を想定しています。そして、この1つ: 'End Sub'の前に一致する 'Sub'がなければなりません。 –

+0

Codebehindファイルを使用しないのはなぜですか? Visual Studioを使用していますか? そうでなければ、このリンクを見てください:http://www.asp101.com/articles/john/codebehindnovs/default.asp しかし、Visual Studio Expressは無料です:http://www.microsoft.com/express/Downloads /#2010-Visual-Basic ページモデル、特にコードビハインドの部分を見てみましょう。http://msdn.microsoft.com/en-us/library/015103yb.aspx –

関連する問題