2

I have a MultiView, that I'm changing the index of. The first time the page loads, and the application runs through themultiview.ActiveViewIndex = 0; The view changes to the first view. ALTHOUGH when I click a linkbutton that changes it to a viewindex of 1. While the autopostback is true, it doesn't work.

I'm not sure what the problem is, but I definitely know that the activeViewIndex only works when the autopostback value is false.

What might the problem be?

Here is my testing code. And what happens is, the view index remains at 1, even if I click it 2-10 times:

int temp = 0;

protected void HyperLink1_Click(object sender, EventArgs e)
{
    if (!(bool)ViewState["IsSigned"])
    {
        Panel11.Visible = true;
        Wizard1.Visible = true;
        Selector.Visible = true;
    }
    else
    {
        //detach cookie
    }
    if (temp == 0)
    {
        LoginView.ActiveViewIndex = 1;
        temp = 1;
    }
    else
    {
        LoginView.ActiveViewIndex = -1;
        temp = 0;
    }
}

How do I fix this problem?

4

1 回答 1

1

Change

int temp = 0;

Into:

private int Temp
{
    get
    {
        if(this.ViewState["temp"] == null)
            return 0;

        return int.Parse(this.ViewState["temp"].ToString());
    }
    set
    {
        this.ViewState["temp"] = value;
    }
}
于 2012-07-14T04:12:43.970 回答