View Link

View Link

Post by TW9ycmlzIE » Thu, 18 Jun 2009 08:22:02


Hi,

I am trying to link from an href or linkbutton on page1 to a view (View3) on
page2.

How do I link to this view and make it active at the same time?
--
Thanks
Morris
 
 
 

View Link

Post by v-thsu » Thu, 18 Jun 2009 12:32:14

i,

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="
 
 
 

View Link

Post by v-thsu » Sat, 20 Jun 2009 18:49:30

i Morris,

How are things going? I would appreciate it if you could post here to let
me know the status of the issue.

If you have any questions or concerns, please don't hesitate to let me
know.

I am happy to be of assistance and look forward to hearing from you.


Microsoft Online Partner Support



microsoft.public.dotnet.framework.aspnet.webcontrols:4739
a
PageLoad
</a>
f

 
 
 

View Link

Post by TW9ycmlzIE » Wed, 24 Jun 2009 03:52:01

Sorry for not replying sooner. You suggestions worked. I have used method 2
- setting href.
--
Thanks for your help.
Morris


"Thomas Sun [MSFT]" wrote:

 
 
 

View Link

Post by v-thsu » Wed, 24 Jun 2009 18:55:38

Hi Morris,

Thanks for your response and I am glad that my reply can help you.

If you have any farther question, please feel free to post it here.


Microsoft Online Partner Support

==================================================


--------------------
microsoft.public.dotnet.framework.aspnet.webcontrols:4745
method 2
let
activate
in
in
redirect
runat="server"
ActiveViewIndex="0" >
ActiveViewIndex="0" >
opposed
Complex
newsgroups.
rights.
(View3)