Monday, March 26, 2012

MultiView containing an UpdatePanel: cant switch ActiveViewIndex?

I have a button control inside of an UpdatePanel. This UpdatePanel sits inside of a MultiView control (which is NOT inside another UpdatePanel, just a regular multiview). The function that is fired from the button click is supposed to change the ActiveViewIndex, but it does not. It fires off other actions inside the function, but does not change the multiview.


Is there something I need to do to get this to work? Here is roughly what I'm talking about. In this case it's set to ActiveViewIndex = 0. I need the button to change it to index 1. Thanks!!

<asp:MultiView runat="server" ID="someID">

<asp:View runat="server"

<asp:UpdatePanel runat="server">

<contenttemplate>

<asp:Button runat="server" onclick="MyFunction" Text="CLICK ME" />

</contenttemplate>

<asp:UpdatePanel>

</asp:View>

<asp:View runat="server">

SOME LITERAL HTML CONTENT

</asp:View>
</asp:MultiView


hi rpeters,

what are you using for your MyFunction?

should be something like this, right?

multiviewAppSec.SetActiveView((

View)this.multiviewAppSec.FindControl("ViewName")));

I was simply using...

myMultiView.ActiveViewIndex = 1;



pixelsyndicate:

hi rpeters,

what are you using for your MyFunction?

should be something like this, right?

multiviewAppSec.SetActiveView((View)this.multiviewAppSec.FindControl("ViewName")));

Tried using the approach as well. No difference... :(

Anyone??


I am pretty sure I tried that before, and didn't get it to work. the definition of that property says its Sets or Gets... so it should work. Try using the

SetActiveView(view) method to make that change. You will have to pass it a reference to the View you want however. Using the findcontrol() method example I used should help you to do that. Respond back on whether it worked or not. ;)


pixelsyndicate:

I am pretty sure I tried that before, and didn't get it to work. the definition of that property says its Sets or Gets... so it should work. Try using the

SetActiveView(view) method to make that change. You will have to pass it a reference to the View you want however. Using the findcontrol() method example I used should help you to do that. Respond back on whether it worked or not. ;)

Tried it...no luck. Same result as by setting the property.


Anyone else? There has to be a way!

you stated you were using 1 as the view index to display. isn't the view you want to show actually the first view? that would mean you need to display view index ZERO (0). indexes are zero-based, meaning its it this order...

0
1
2
3
4
5
6
...


pixelsyndicate:

you stated you were using 1 as the view index to display. isn't the view you want to show actually the first view? that would mean you need to display view index ZERO (0). indexes are zero-based, meaning its it this order...

0
1
2
3
4
5
6
...

I know that they are zero-based indices. I also am using the correct view index for my application. The problem is that it seems that because it is being called from a routine that is inside of an update panel, it is trying to make the change inside that panel, rather than changing the entire page to reflect the new panel.

anyone else?? thanks.

No comments:

Post a Comment