1Public Enum webpages
 2        yet_test1
 3        yet_test2
 4        yet_m_test2
 5        yet_m_test1
 6    End Enum

 7
 8    <ToolboxData("<{0}:Forum runat=""server""></{0}:Forum>")> _
 9    Public Class class1
10        Inherits System.Web.UI.UserControl
11
12        Private Sub Forum_load(ByVal sender As ObjectByVal e As EventArgs)
13            Dim webpages1 As webpages
14            Dim m_baseDir As String = config.ConfigSection.Item("root")
15            Try
16                webpages1 = CType([Enum].Parse(GetType(webpages), MyBase.Request.QueryString.Item("g"), True), webpages)
17            Catch ex As Exception
18                webpages1 = webpages.yet_m_test1
19            End Try
20            Dim src As String = String.Format("{0}/{1}.ascx", m_baseDir, webpages1)
21
22            'Try
23            '    Dim webpage As ForumPage = CType(MyBase.LoadControl(src), ForumPage)
24            '    webpage.ForumControl = Me
25            '    Me.Controls.Add(webpage)
26            'Catch exception2 As System.IO.FileNotFoundException
27            '    Throw New ApplicationException(("Failed to load " & m_baseDir & "."))
28            'End Try
29
30
31
32        End Sub


 1Private m_section As System.Xml.XmlNode
 2
 3        Public Sub config(ByVal node As System.Xml.XmlNode)
 4            m_section = node
 5        End Sub

 6
 7        Public ReadOnly Property Item(ByVal key As StringAs String
 8            Get
 9                Dim node As System.Xml.XmlNode = m_section.SelectSingleNode(key)
10                If Not node Is Nothing Then
11                    Return node.InnerText
12                Else
13                    Return Nothing
14                End If
15            End Get
16        End Property

17
18        Public Shared ReadOnly Property ConfigSection() As config
19            Get
20                Dim config1 As config = CType(ConfigurationSettings.GetConfig("yafnet"), config)
21                If (config1 Is NothingThen
22                    Throw New ApplicationException("Failed to get configuration from Web.config")
23                Else
24                    Return config1
25                End If
26            End Get
27        End Property
 

posted on 2005-06-12 16:31  T_98Dsky   阅读(836)  评论(0编辑  收藏  举报