If you want to redirect to the same page and set the active view directly, you can try to use Query string or
Session to transfer the value. Then use the method MultiView.SetActiveView to set the specified
View control to the active view within a MultiView control. Please check the demo below:
int id;
if (Request.Params.Get("id") != null)
{
id = int.Parse(Request.Params.Get("id"));
}
else
{
id = 0;
}
if (id == 1)
{
MultiView1.SetActiveView(LoginView1);
}
else if (id == 2)
{
MultiView1.SetActiveView(PasswordView);
}
mohamedaly
0 Points
12 Posts
How to select(set) active view in another page
Apr 23, 2012 02:31 PM|LINK
Hey All
I want to redirect from one page to another page and set(select)active view in this page according to my selection
ex: if i click link(forget password) in this page it redirect me to another page and set active view >> forget password view
& if i click another link(login) it redirect me to the same another page with active view >>login view
How I do That With Or Without Query String Method ...All Possible Solutions Please ..
Thanks In Advance
Shankar_ss
Participant
1270 Points
279 Posts
Re: How to select(set) active view in another page
Apr 23, 2012 02:38 PM|LINK
In your button click event include
response.redirect(page.aspx?id=1) for login
response.redirect(page.aspx?id=2) for password change
In your new page, on pageload get the query string value by:
If Request.Params.Get("id") <> "" Then
id = Request.QueryString("id")
Else
id = 0
End If
if id=1 then
--display login view
elseif id=2 then
--display forgot password view
Hope this helps.
Shankar
Catherine Sh...
All-Star
23382 Points
2490 Posts
Microsoft
Re: How to select(set) active view in another page
Apr 25, 2012 03:02 AM|LINK
Hi mohamedaly,
If you want to redirect to the same page and set the active view directly, you can try to use Query string or Session to transfer the value. Then use the method MultiView.SetActiveView to set the specified View control to the active view within a MultiView control. Please check the demo below:
One.aspx
<asp:LinkButton ID="Login_Link" Text="Go to login view" OnCommand="LinkButton_Command" CommandArgument="login" CommandName="Link" Width="300px" runat="Server"> </asp:LinkButton> <br /> <asp:LinkButton ID="Forgetpassword_Link" Text="Go to forget password view" OnCommand="LinkButton_Command" CommandArgument="password" CommandName="Link" Width="300px" runat="server"> </asp:LinkButton><br />One.cs
public void LinkButton_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e) { switch (e.CommandArgument.ToString()) { case "login": Response.Redirect("page.aspx?id=1"); break; case "password": esponse.Redirect("page.aspx?id=2"); break; } }page.aspx
<asp:MultiView ID="MultiView1" runat="Server"> <asp:View ID="LoginView1" runat="Server"> <asp:Label ID="Label1" runat="server" Text="login view"></asp:Label> </asp:View> <asp:View ID="PasswordView" runat="Server"> <asp:Label ID="Label2" runat="server" Text="password view"></asp:Label> </asp:View> </asp:MultiView>page.cs
int id; if (Request.Params.Get("id") != null) { id = int.Parse(Request.Params.Get("id")); } else { id = 0; } if (id == 1) { MultiView1.SetActiveView(LoginView1); } else if (id == 2) { MultiView1.SetActiveView(PasswordView); }One.aspx
<asp:LinkButton ID="Login_Link" Text="Go to login view" OnCommand="LinkButton_Command" CommandArgument="login" CommandName="Link" Width="300px" runat="Server"> </asp:LinkButton> <br /> <asp:LinkButton ID="Forgetpassword_Link" Text="Go to forget password view" OnCommand="LinkButton_Command" CommandArgument="password" CommandName="Link" Width="300px" runat="server"> </asp:LinkButton><br />One.cs
public void LinkButton_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e) { switch (e.CommandArgument.ToString()) { case "login": Session["id"]=1; break; case "password": Session["id"] = 2; break; } Response.Redirect("page.aspx"); }page.aspx
<asp:MultiView ID="MultiView1" runat="Server"> <asp:View ID="LoginView1" runat="Server"> <asp:Label ID="Label1" runat="server" Text="login view"></asp:Label> </asp:View> <asp:View ID="PasswordView" runat="Server"> <asp:Label ID="Label2" runat="server" Text="password view"></asp:Label> </asp:View> </asp:MultiView>page.cs
if (Session["id"].ToString()=="1") { MultiView1.SetActiveView(LoginView1); } else if (Session["id"].ToString() == "2") { MultiView1.SetActiveView(PasswordView); }In addition, you can use cookie to transfer the value, too.
Best wishes,
Feedback to us
Develop and promote your apps in Windows Store
mohamedaly
0 Points
12 Posts
Re: How to select(set) active view in another page
Apr 30, 2012 07:11 AM|LINK
Thank U Very Much Your Answer Help Me ..