DotNetNuke部分类控制

时间:2012-09-18 16:36:31

标签: vb.net user-controls parameters dotnetnuke

我正在使用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

1 个答案:

答案 0 :(得分:1)

标记,

尝试记住,但我认为您可能需要将Page_Load代码移动到prerender事件。如果我没记错的话(自从我开始研究一个项目以来已经过了一段时间),该属性在页面循环中填充太晚,无法在预处理器中处理的页面加载中工作。

我可能错了-----:)