0

我正在使用 DotNetNuke 并创建一个 ASCX 调用 TutorialsAll.ascx 和第二个调用 TutorialsByLevel.ascx。TutorialsByLevel.ascx 目前在 TutorialsAll.ascx 中使用了 4 次。

在 TutorialsByLevels.ascx 我有一个TutorialTypeID从 TutorialsAll.ascx 开始的公共属性。

我已经添加了下面的代码,任何人都知道为什么不这样做,以及我如何使它工作,非常感谢。

TutorialsAll.ascx:

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="TutorialsAll.ascx.vb" Inherits="Portals_0_open_TutorialsAll" %>
<%@ Register TagPrefix="mark" TagName="tutorial" Src="TutorialsByLevel.ascx" %>
<div class="Tut_Column"><mark:tutorial ID="TutorialBasic1" TutorialType=1 runat="server" /></div>
<div class="Tut_Column"><mark:tutorial ID="TutorialBasic2" TutorialType=2 runat="server" /></div>
<div class="Tut_Column"><mark:tutorial ID="TutorialBasic3" TutorialType=3 runat="server" /></div>
<div class="Tut_Column"><mark:tutorial ID="TutorialBasic4" TutorialType=4 runat="server" /></div>

TutorialsByLevel.ascx:

Partial Class Portals_0_open_TutorialsByLevel
Inherits System.Web.UI.UserControl

Dim _Type As Integer

Public Property TutorialType(ByVal TypeID As Integer) As Integer
    Get
        Return _Type
    End Get
    Set(ByVal value As Integer)
        _Type = value
    End Set
End Property

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ToString)
    conn.Open()

    Dim sql As String = "SELECT * FROM Prez_Stories WHERE Tut_Show = 1 AND Tut_Level = " & _Type & "ORDER BY Tut_Order"
    Dim sqlCmd As SqlCommand = New SqlCommand(sql, conn)
    Dim myReader As SqlDataReader
    myReader = sqlCmd.ExecuteReader

    Dim s As StringBuilder = New StringBuilder("")

    s.Append("<div=""tutorialBlock"">TutorialType = " & _Type)
    Do While myReader.Read
        s.Append("<div id=""newTutorial"">" & myReader("Title"), "<br/>" & myReader("Summary") & "<div>")
    Loop
    s.Append("</div>")

    Literal1.Text = s.ToString
End Sub
End Class
4

1 回答 1

1

标记,

试图记住,但我认为您可能必须将 Page_Load 代码移动到 prerender 事件。如果我没记错的话(自从我从事一个项目以来已经有一段时间了)该属性在页面周期中填充得太晚,无法在您必须在预渲染中处理的页面加载中工作。

我可能是错的-----:)

于 2012-10-09T18:33:03.013 回答