Hi,
From your description, I understand that you want to know how to activate a
View of ASP.NET MultiView control when page is requested. If I have
misunderstood you, please feel free to let me know.
When page is loading, we can specify which View will be activated in
PageLoad event by setting MultiView's ActiveViewIndex property. In this
case, the page is redirected from another page, we can use query string in
URL or Session object to pass which view will be activated.
For example, there are two pages, PageA and PageB, and MultiView exists in
PageB.
##1. Use LinkButton's Click event to set active View's index and redirect
to PageB. In PageB, we get index from Session and activate View in PageLoad
event.
PageA=================
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void LinkButton1_Click(object sender, EventArgs e)
{
Session["ViewIndex"] = 2;
Response.Redirect("DefaultB.aspx");
}
</script>
<html xmlns="
http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Use LinkButton <asp:linkbutton ID="LinkButton1" runat="server"
OnClick="LinkButton1_Click">LinkButton</asp:linkbutton><br /><br />
</div>
</form>
</body>
</html>
PageB===================
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (Session["ViewIndex"] != null)
{
int iIndex = 0;
try
{
iIndex = Convert.ToInt32(Session["ViewIndex"]);
}
catch
{
}
if (iIndex > 0 && iIndex < MultiView1.Views.Count)
{
MultiView1.ActiveViewIndex = iIndex;
}
}
}
</script>
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:multiview ID="MultiView1" runat="server" ActiveViewIndex="0" >
<asp:view ID="View1" runat="server" >
This is View1.</asp:view>
<asp:view ID="View2" runat="server">
This is View2.</asp:view>
<asp:view ID="View3" runat="server">
This is View3.</asp:view>
</asp:multiview> </div>
</form>
</body>
</html>
##2. To use HTML link, we can specify View index in it. For example:
<a href="DefaultB.aspx?ViewIndex=2">Redirect Page B and activate View 3 </a>
In PageB, we retrieve value from requested URL in PageLoad event:
=====================
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
string strIndex = Request.QueryString["ViewIndex"].ToString();
int iIndex = 0;
try
{
iIndex = Convert.ToInt32(strIndex);
}
catch
{
}
if (iIndex > 0 && iIndex < MultiView1.Views.Count)
{
MultiView1.ActiveViewIndex = iIndex;
}
}
</script>
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:multiview ID="MultiView1" runat="server" ActiveViewIndex="0" >
<asp:view ID="View1" runat="server" >
This is View1.</asp:view>
<asp:view ID="View2" runat="server">
This is View2.</asp:view>
<asp:view ID="View3" runat="server">
This is View3.</asp:view>
</asp:multiview> </div>
</form>
</body>
</html>
For more information about PageLoad event, see
http://msdn.microsoft.com/en-us/library/ms178472.aspx
For more information about passing value between pages, see
http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx
For more information about MultiView and View Web Server Controls, see
http://msdn.microsoft.com/en-us/library/ms227665(VS.85).aspx
I look forward to receiving your test results.
--
Best Regards,
Thomas Sun
Microsoft Online Partner Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
to the limited number of phone-based technical support incidents. Complex
issues or server-down situations are not recommended for the newsgroups.
Issues of this nature are best handled working with a Microsoft Support
Engineer using one of your phone-based incidents.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------