在返回 CommandEventArgs 的用户控件内引发事件
大家好,我有以下问题:
我有一个用户控件,我想从使用该用户控件(它是一个按钮)的页面引发一个事件,
无论如何,当我想将此用户控件放入中继器中时,我的问题就开始了而不是另一个按钮(常规 asp:button) 无论如何,我需要支持 CommandArgument,以便页面可以使用该按钮
,因此我创建了一个属性:
Private m_CommandArgument As Object
Public Property CommandArgument() As Object
Get
Return m_CommandArgument
End Get
Set(ByVal Value As Object)
m_CommandArgument = Value
End Set
End Property
但是...当我尝试引发事件时,该属性不会保持他的状态...
cmdEvent = New CommandEventArgs(CommandName, CommandArgument)
所以在我按下按钮并发生回发后引发的事件没有价值.. 该属性应该保存在哪里才能使其在回发后具有值? 查看状态?如何自动添加到视图状态?
谢谢!
hi all i have the following problam:
i have a user control which i want to raise an event from to the page that is using that user control (its a button)
anyway my problem started when i wanted to put this user control inside a repeater instead of another button (regular asp:button)
anyway i needed to support CommandArgument so that page can use the button
so i created a property:
Private m_CommandArgument As Object
Public Property CommandArgument() As Object
Get
Return m_CommandArgument
End Get
Set(ByVal Value As Object)
m_CommandArgument = Value
End Set
End Property
but... when i try to raise the event this property dosnt keep his state...
cmdEvent = New CommandEventArgs(CommandName, CommandArgument)
so after i press the button and the postback happen my raised event dosnt have a value..
where should this property be saved in order for it to have a value after postback?
view state? how do i add to the the viewstate automaticly?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,所以我想出了一种方法可以做到这一点...
它非常简单,如下所示:
所以实际上只是将其保存在视图状态中...
ok so i figured out a way i can do this...
and its very simple like so:
so actualy simply saving it in the viewstate...