Hi,Ive googled this problem, and found a few threads, but its not fixing my issue. I have a user control (myheader.ascx) in which I programatically set 2 variables. I am trying to get the value of these variables in an aspx page, but the values are always nothing. I can reference the values in the aspx.vb code behind.Heres what Im doing, does anyone have any suggestions ?? Thanks very much!!mike123 Private _isFrom_Search As BooleanPrivate _SearchGender_forBind As StringPublic Property isFrom_Search() As BooleanSet(ByVal Value As Boolean)If Not String.IsNullOrEmpty(Value) Then_isFrom_Search = ValueEnd IfEnd SetGetReturn _isFrom_SearchEnd GetEnd PropertyPublic Property SearchGender_forBind() As StringSet(ByVal Value As String)If Not String.IsNullOrEmpty(Value) Then_SearchGender_forBind = ValueEnd IfEnd SetGetReturn _SearchGender_forBindEnd GetEnd Property and in the aspx.vb page I have these 2 lines : (these are excerpts obviously =])If myHeader.isFrom_Search = True ThenSelect Case myHeader.SearchGender_forBind.
discussion1:Maybe you reference them in your page in the event handler, that executes before the controls event handler, that initializes those variables? Try to play with the breakpoints..
discussion2:mike123:.
discussion3:Hey Guys,I am setting the values in my myHeader.ascx page on this subPrivate Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load I am attempting to retrieve them on the aspx.vb page, on this sub:Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Regarding the steps:1.) ok2.) ok if the user control is created with no default values3.) ok I am setting a property either false or true, and I am always retreiving NULL in the aspx.vb page4/5.) what do you mean by potentially initializing? Any further help is greatly appreciated !! .. still pretty suck on this .. thanks agian,mike123.
discussion4:You need to set a breakpoint in your page_load of the aspx and watch the order everything happens.I have a feeling that your problem is the page life cycle of the page and the user control..
discussion5:hi scriptstudios, good point... after stepping thru my code, I have realized that the Page_load of the aspx file actually fires before the Page_Load of the ascx file.Does this mean what I am trying to do is not possible ? At this point it sure seems like it.since the value passed is determined programmatically, passing a default value is not an option.youve been a great helpthanks again!mike123.
discussion6:I think you need to add a string property rather then Bool to check that it works,Remember a point, If you use simple property types such as int, DateTime, float, and so on, you can still set them with stringvalues when declaring the control on the host page. ASP.NET will automatically convert the string to the propertytype defined in the class..
discussion7:Hi,Isnt passing datatypes and relying on implicit conversion bad practice ? I tried doing this but no luck ...... Can anyone chime in here and comfirm its definately possible ? This issues killing me thanks again,mike123.