MultiView ActiveViewChanged - raised before OnInit of page?

D

DC

Hi,

the subject says it all, I have a MultiView on a page an the
ActiveViewChanged is being raised on first load even before the OnInit
event of the page is being raised. Is that normal (and where can I
learn about such event order; on the typical page life cycle chart I
don't get such behaviour).

TIA for any hints!

Regards
DC
 
Joined
Sep 25, 2011
Messages
1
Reaction score
0
yes I think that's normal, this might be the reason,
because this event is not directly triggered by user action like any other common events (e.g. button_click, listbox_selectedindexchanged).
This event (ActiveViewChanged) is triggered by your code, while setting the ActiveViewIndex. Which is usually you put it inside other event which directly respond to user action (click, keyup, keydown, mouseup, selectedindexchanged).
As you need other event to trigger the MultiView_ActiveViewChanged, then you won't need to restart the page life cycle. If this event need to restart the page life cycle (..Init-Page_Load-..), that would cause double cycles.

button_click.. --> this is common event which is through a full life cycle (..-Init - Page_Load - button_click - ..)
{
multiView.ActiveViewIndex = 0; --> this will trigger MultiView_ActiveViewChanged directly without restarting the cycle as it's already done by the button.
}

so you need to be careful because setting the default attribute - ActiveViewIndex - will also cause direct calling after MultiView_Init before Page_Init and Page_Load,

<asp:MultiView id="DevPollMultiView"
ActiveViewIndex="0"
runat="Server">

the workaround for this is instead of setting the default ActiveViewIndex attribute by design, you should set it by code after any value you need are set up in Page_Init or Page_Load.

CMIIW.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top