您好我的网站有usercontrol,我可以加载控件。但是,如果我分配用户控件的属性值,我得到错误“类型”WebUserControl)没有定义。有人能告诉我如何解决它。提前谢谢。
有使用我的Usercontrol的代码
Partial Class Test
Inherits System.Web.UI.Page
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
Dim ctrl As Control
ctrl = Page.LoadControl("Management/Profile/WebUserControl.ascx")
ctrl.ID = "ctrl_1"
CType(ctrl, WebUserControl).Level = 6 //this line cause error
PlaceHolder1.Controls.Add(ctrl)
End Sub
End Class
这是我的WebUserControl
Partial Class Management_Profile_WebUserControl
Inherits System.Web.UI.UserControl
Private m_Level As Integer
Public Property Level() As Integer
Get
Return m_Level
End Get
Set(ByVal Value As Integer)
m_Level = Value
End Set
End Property
Protected Sub Management_Profile_WebUserControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Text = m_Level
End Sub
End Class