1

我需要将 C# 网站转换为 VB。有一个页面会加载自定义 Web 控件 (WholeLife.ascx),然后在此控件中,可能会动态加载多个 Web 用户控件 (WholeLifeChild.ascx)。C# 版本有效,VB 版本似乎无法识别它需要在主控件 (WholeLife.ascx) 中加载的控件 (WholeLifeChild.ascx)。

C#版本(作品):

private WholeLifeChild _selectedChild;

// 稍后,使用 foreach 循环会创建加载多个 childChoice:

WholeLifeChilds childChoice = (WholeLifeChilds)LoadControl("~/Controls/WholeLifeChild.ascx");
phChildChoices.Controls.Add(childChoice);
childChoice.ID = "ChildChoices-" + appRate.DependentID;
childChoice.Initialize(appRate, _WholeLifeCoverage);
childChoice.ChildChoicesChanged += new WholeLifeChild.ChangingHandler(ChildChoices_Changed);

VB版(找不到自定义网页用户控件):

Private _selectedChild As WholeLifeChild **(vb complains here on WholeLifeChild)**

'稍后,使用 foreach 循环会创建加载多个 childChoice:(VB 抱怨WholeLifeChild好像它无法找到它)

Dim childChoice As WholeLifeChild = DirectCast(LoadControl("~/UserControls/WholeLifeChild.ascx"), WholeLifeChild)
phChildChoices.Controls.Add(childChoice)
childChoice.ID = "ChildChoices-" + appRate.DependentID
childChoice.Initialize(appRate, _WholeLifeCoverage)
childChoice.ChildChoicesChanged += New WholeLifeChild.ChangingHandler(AddressOf ChildChoices_Changed)

'此 VB 版本找不到 WholeLifeChild.ascx 控件,该控件与其加载到的控件 (WholeLife.ascx) 位于同一目录中。

任何帮助将不胜感激。

4

0 回答 0