문제

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!

도움이 되었습니까?

해결책

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...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top