Problem getting ActiveViewIndex

  • Thread starter Thread starter antonyliu2002
  • Start date Start date
A

antonyliu2002

My web form has a MultiView which has 4 Views. 4 LinkButtons on the
web form activates each of the 4 views.

The 4 views have been hiding and showing nicely depending upon which
LinkButton is clicked.

But, when I try to get the ActiveViewIndex when the [Submit] button is
clicked, I always get 0. Or if I do

Multiview1.GetActiveView().ID;

I always get the name of the first view.

What is wrong? I googled, but haven't found anyone experiencing this
problem yet.
 
My web form has a MultiView which has 4 Views. 4 LinkButtons on the
web form activates each of the 4 views.

The 4 views have been hiding and showing nicely depending upon which
LinkButton is clicked.

But, when I try to get the ActiveViewIndex when the [Submit] button is
clicked, I always get 0. Or if I do

Multiview1.GetActiveView().ID;

I always get the name of the first view.

What is wrong? I googled, but haven't found anyone experiencing this
problem yet.

As a follow-up, I did set the active view index when a linkbutton is
clicked, like so:

MultiView1.ActiveViewIndex = 0; or
MultiView1.ActiveViewIndex = 1; or
MultiView1.ActiveViewIndex = 2; or
MultiView1.ActiveViewIndex = 3;
 
My web form has a MultiView which has 4 Views. 4 LinkButtons on the
web form activates each of the 4 views.

The 4 views have been hiding and showing nicely depending upon which
LinkButton is clicked.

But, when I try to get the ActiveViewIndex when the [Submit] button is
clicked, I always get 0. Or if I do

Multiview1.GetActiveView().ID;

I always get the name of the first view.

What is wrong? I googled, but haven't found anyone experiencing this
problem yet.

Again, it is because of the postback ghost.

In Page_Load, I did

MutiView1.ActiveViewIndex = 0;

Wrapping it up with

if (!Page.IsPostBack)
{
// That ghost line here.
}

Solves the problem.

Question: Does a page ALWAYS post back to itself when any button is
clicked? On my web form I attempt to redirect to another page
through:

Response.Redirect("AnotherPage.aspx");

when the [Submit] button is clicked.

It looks like that the web form is posted back to itself, such that if
you don't do

if (!Page.IsPostBack)

, the ActiveViewIndex will again be set to 0. Right?
 
Have you tried storing the activeview in a session variable, updated each
time the buttons are clicked?

Ross
 
Have you tried storing the activeview in a session variable, updated each
time the buttons are clicked?

Ross


My web form has a MultiView which has 4 Views. 4 LinkButtons on the
web form activates each of the 4 views.
The 4 views have been hiding and showing nicely depending upon which
LinkButton is clicked.
But, when I try to get the ActiveViewIndex when the [Submit] button is
clicked, I always get 0. Or if I do
Multiview1.GetActiveView().ID;

I always get the name of the first view.
What is wrong? I googled, but haven't found anyone experiencing this
problem yet.

No, there is not need to do that now.
 

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

Back
Top