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