Pass parameter to webusercontrol
-
Hi everyone, I'm building a page which has a webusercontrol on it. The webusercontrol is there for the sole purpose of displaying controls(calendar, texbox, etc...) on demand. The parameters the webusercontrol uses to detirmine what to show, is given by the page the webusercontrol is on. How can I pass a parameter from the page to the webusercontrol ? I'll need to build some sort of 'listener' in the webusercontrol I built, but I'm not sure how to go about doing that. Some help would be much appreciated.
-
Hi everyone, I'm building a page which has a webusercontrol on it. The webusercontrol is there for the sole purpose of displaying controls(calendar, texbox, etc...) on demand. The parameters the webusercontrol uses to detirmine what to show, is given by the page the webusercontrol is on. How can I pass a parameter from the page to the webusercontrol ? I'll need to build some sort of 'listener' in the webusercontrol I built, but I'm not sure how to go about doing that. Some help would be much appreciated.
I would suggest simply storing the values you need for the web user control in a Session variable. But pay attention to the order of events so you know where to store the change, I believe the user control is dealt with after the Page Load but before the button click so you would need to have a call to that logic in the Page Load or earlier.
Cleako
-
I would suggest simply storing the values you need for the web user control in a Session variable. But pay attention to the order of events so you know where to store the change, I believe the user control is dealt with after the Page Load but before the button click so you would need to have a call to that logic in the Page Load or earlier.
Cleako
What would that look like in code ? Take into account that there could be 0 to N parameters being returned. And there can be several parameters of the same type. For instance: More than one date parameter required, which means that it should return two or more calendar controls on screen.
-
What would that look like in code ? Take into account that there could be 0 to N parameters being returned. And there can be several parameters of the same type. For instance: More than one date parameter required, which means that it should return two or more calendar controls on screen.
I suppose you could build something similar to a comma separated string and store it so it would be
Session("WUCParameters") = ParamValue1,ParamValue2,ParamValue3
then on the Web User Control you simply split it into a string array.Dim arParams() as String = Session("WUCParameters").ToString.Split(",") For i as Integer = 0 to arParams.GetUpperBound() 'Do something for each value listed Next
Cleako