作者danceric (蜥蝪)
看板Visual_Basic
标题[.NET] 再问~~Property的问题~
时间Sun Oct 15 03:19:13 2006
各位大大好~我又来问问题了 冏~~z
先说我想做些什麽好了
就如上篇所问的 我把我webform中的东西 全部用一个object阵列包起来
想要传到user control去做一些处理
感谢大大的回答 我可以顺利的找出阵列中原本的东西
但现在又面临到一个问题 要怎麽把原本在webform中的阵列传到user control中
以我的理解好像是可以用session或是property来做
我选择了用property来实作
以下是我在user control中写的
=====================================================
Property sendComponents() As Object()
Get
Return Me.ViewState("sendComponents")
End Get
Set(ByVal Value As Object())
Me.ViewState("sendComponents") = Value
Me.rcvComponents = sendComponents
End Set
End Property
=====================================================
我在webform中写了以下几行程式想要传递阵列过去
=====================================================
Dim Mycontrol As WebUserControl11
Mycontrol = Me.FindControl("WebUserControl1")
Mycontrol.sendComponents = allComponent
=====================================================
可是却会发生"并未将物件参考设定为物件的执行个体"的错误
以在下的理解是
Dim allComponent() As Object = {Me.TextBox1, Me.TextBox2, Me.CheckBox1,
Me.CheckBox2, Me.DropDownList1, Me.TextBox3}
这个部份的allComponent是一个物件参考变数 分别指向textbox1,textbox2等等~
但是并没有真的的生出实体来
可是我就卡在这个地方不知道该怎麽做才好
又要麻烦大大们罗
文章有些长 先感谢大家耐心的看完~~
拜托各位罗~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.132.182.104
1F:推 fumizuki:FindControl() 有找到物件吗 10/15 10:36
2F:推 diskk:Property有用Public或Protected宣告吗 10/15 11:09
3F:推 danceric:要怎麽确定是否有找到物件? 刚刚试了一下似乎是没有= = 10/15 14:22
4F:→ danceric:property没有宣告public之类的 我现在加上去了@@~~ 10/15 14:22
5F:推 danceric:所以我的理解好像是错的=.= 应该是findcontrol那边的问题 10/15 14:25
6F:推 danceric:可以了~~感谢大大们~~:D 10/15 14:44