If I call the method from the controls Page_Load the Property has not
been initialized yet!
currently I've moved my call to LoadFromDB to the PreRender Event
handler, by which time the Property passed in the markup has been
initialized?
My question still stands, I can make it work by putting it in all sorts
of places, but where is the correct one.
At the Point that Page_Init and Page_Load fire the property has a value
of -1 (the default). Is there an attribute I should be applying to the
property? or any other way to get the property initialized sooner?
Is there a more appropriate group for this question?
Walter Wang [MSFT] wrote:
> Hi,
>
> The image's DataBinding event will only be fired when your usercontrol is
> putting inside a control that is binding to data. You should put the call
> to LoadFromDB inside your usercontrol's Load event:
>
> <%@ Control Language="C#" AutoEventWireup="true" ...
>
>
> protected void Page_Load(object sender, EventArgs e)
> {
> if (!Page.IsPostBack)
> {
> LoadFromDB();
> }
> }
>
> This is assuming your image and TextBox have enabled ViewState; if not
> enabled, you should not check Page.IsPostBack and call LoadFromDB() in
> every postback.
>
> Regards,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>