在返回 CommandEventArgs 的用户控件内引发事件

发布于 2024-10-05 19:26:37 字数 654 浏览 0 评论 0原文

大家好,我有以下问题:

我有一个用户控件,我想从使用该用户控件(它是一个按钮)的页面引发一个事件,

无论如何,当我想将此用户控件放入中继器中时,我的问题就开始了而不是另一个按钮(常规 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日记撕了你也走了 2024-10-12 19:26:37

好吧,所以我想出了一种方法可以做到这一点...

它非常简单,如下所示:

Private m_CommandArgument As Object
Public Property CommandArgument() As Object
    Get
        'Return m_CommandArgument
        Return ViewState("confirmCommandArgument")
    End Get

    Set(ByVal Value As Object)
        ViewState("confirmCommandArgument") = Value
        'm_CommandArgument = 
    End Set
End Property

所以实际上只是将其保存在视图状态中...

ok so i figured out a way i can do this...

and its very simple like so:

Private m_CommandArgument As Object
Public Property CommandArgument() As Object
    Get
        'Return m_CommandArgument
        Return ViewState("confirmCommandArgument")
    End Get

    Set(ByVal Value As Object)
        ViewState("confirmCommandArgument") = Value
        'm_CommandArgument = 
    End Set
End Property

so actualy simply saving it in the viewstate...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文