Properties in page lifecycle?

Vote:
 

I have a control within a page which needs a value to be passed to it but when I try and put in an episerver value it cant see it?

<uc2:NowPlaying ID="myControl" runat="server" ArticleID=<%# CurrentPage["testString"].ToString() %> />

but the follwoing works fine

<uc2:NowPlaying ID="NowPlaying1" runat="server" ArticleID=90 />

The control needs the property from th epage to work, I cant put the property in the control as sometimes its not the data from teh current page which will be used.

#20200
May 22, 2008 12:53
Vote:
 

It is probably a data binding problem in ASP.NET, the property in the PageData object should be there if it has a value. The <%# tags requires databinding to be evaluated, the second example code does not require databinding.

#20205
May 22, 2008 13:27
Vote:
 

Yes the value is there in the aspx page when I dubug but its not pusing through to the ascx control? I was wondering if its trying to render the control before evaulating the property which is needed within it or something?

#20207
May 22, 2008 13:41
Vote:
 

Could be, where are you databinding (the actual call to DataBind()) and where is the logic done in the NowPlaying? By "where" I mean in which event in the page life cycle.

A quick fix is to assign ArticleID in the OnInit event in code behind instead.

#20218
May 22, 2008 15:45
Vote:
 

I tried this

Episerver property = <EPiServer:Property ID="Property1" runat="server" PropertyName="test" /><br />

ASP Literal = <asp:Literal ID="test" runat="server" Text=<%# CurrentPage["test"].ToString() %> /><br />

and it outputs the following

Episerver property = 87
ASP Literal =

 So why are they outputting differant things when they referance the same property??

#20220
May 22, 2008 15:49
Vote:
 

Im not databinding, its a property of the page not a list or something?

#20221
May 22, 2008 15:54
Vote:
 
I hav ejust called databind on my control and it works? Why Do I need to call that when its a property of the page? Does databind have to be called on EVERYTHING then?
#20222
May 22, 2008 16:01
Vote:
 

Well, <%# is the magic ASP.NET keyword for databinding, it will not be evaluated if you don't call DataBind. Otherwise just assign the values from code behind instead.

#20223
Edited, May 22, 2008 16:10
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.