0

Hello,

I have a custom control I have made and I would like to use a dynamic variable assigned in the code behind of the aspx page.

I would like to pass a variable called topic to the control.
Here is the property of the control:

Property Topic() As String
        Get
            Return _Topic
        End Get
        Set(ByVal value As String)
            _Topic = value
        End Set
    End Property

The control is placed as so in the front end of my aspx page:

<MYControl:MY runat="server" id="MYID" Topic="TEST" />

and in the page load of the code behind I have:

MYID.Topic = "something"

With all of the above considered, the topic variable is sent as Test, and not something.
If I remove Topic=Test from the tag on the front end, then Topic is sent as null. I have tried so many different variations but for some reason Topic is always null. Every solution I seem to come accross seems to suggest I do what I have just posted. The only thing I am asking to do is be able to dynamically set the topic variable in code behind.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by __avd
0

Use ViewState.

Property Topic() As String
        Get
            If IsNothing(ViewState("Topic")) Then
                Return String.Empty
            Else
                Return ViewState("Topic").ToString()
            End If
        End Get
        Set(ByVal value As String)
            ViewState("Topic") = value
        End Set
    End Property
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.