Response.Redirect from within a user control affects browser histo

D

DCarroll

I have an ASP .NET user control containing a data grid. The data grid has a
column containing hyperlinks that redirect the user to the view page
associated with their selection in the grid.

This user control is hosted in another page and displayed to the user.

When the user follows a link from within the user control, their browser
history is reduced to a single entry - the page hosting the user control.
All other history is removed from IE's back button history.

I have moved all the code and the data grid from the user control into the
hosting page ( removing the user control temporarily ) and I do NOT see the
same thing happening in the browser's history. The history remains intact
when following links from the non-user control data grid.

How can I keep the browser's history intact and still make use of the user
control? The user control is used in 6 other pages, so I'd really rather not
just copy the code out of the control and duplicate it in each page.

This does NOT happen in FireFox, only Internet Explorer. In FF the history
remains in stact, as expected.

Thanks!
--DCarroll
 
S

Steven Cheng[MSFT]

Hi DCarroll,

Welcome to MSDN newsgroup.
From your description, you have a web page which contains a UserControl,
in the UserControl it contains a DAtaGrid which contains a certain column
by clicking which the user will be redirected to a DetailsView page.
Currently you find that when user be redirected to the new page, the IE
browser's history list always be reduced to one item?

As for the problem, do you means that the orignial page's record will
disappear in the history list? Based on my local test, it seems the
problem maybe application or environment specific. I used a simple aspx
page and a Usercontrol which contains a DataGrid and I tried using both
hyperlink or Linkbutton(with Resposne.Redirect) to redirect user to another
aspx page. However, I didn't get any strange or unexpected behavior in the
IE browser's history list. Have you tried using a simple page/usercontrol
to see whether you get the same result? If possible, you can provide me a
simple page/usercontrol so that we can perform some further tests by them
on ourside.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




--------------------
| Thread-Topic: Response.Redirect from within a user control affects
browser histo
| thread-index: AcW/xVA4rElmEGyFRSaJQMNhb59aiw==
| X-WBNR-Posting-Host: 198.6.95.95
| From: "=?Utf-8?B?RENhcnJvbGw=?=" <[email protected]>
| Subject: Response.Redirect from within a user control affects browser
histo
| Date: Thu, 22 Sep 2005 15:31:02 -0700
| Lines: 24
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:4231
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| I have an ASP .NET user control containing a data grid. The data grid
has a
| column containing hyperlinks that redirect the user to the view page
| associated with their selection in the grid.
|
| This user control is hosted in another page and displayed to the user.
|
| When the user follows a link from within the user control, their browser
| history is reduced to a single entry - the page hosting the user control.

| All other history is removed from IE's back button history.
|
| I have moved all the code and the data grid from the user control into
the
| hosting page ( removing the user control temporarily ) and I do NOT see
the
| same thing happening in the browser's history. The history remains
intact
| when following links from the non-user control data grid.
|
| How can I keep the browser's history intact and still make use of the
user
| control? The user control is used in 6 other pages, so I'd really rather
not
| just copy the code out of the control and duplicate it in each page.
|
| This does NOT happen in FireFox, only Internet Explorer. In FF the
history
| remains in stact, as expected.
|
| Thanks!
| --DCarroll
|
 
D

DCarroll

Steven,
Thanks for your quick response. I've been doing some further testing, and
have some results and some sample code for you. The problem seems to be
related to the number of row in the datagrid being displayed. I'm pasting
code at the bottom of this post, but not data. The xml doc feeding this gets
a little large - I can post it if you like, or can you email me directly and
I can reply with the xml doc?

Quick review of my testing/results:

index.aspx has a link to page2.aspx.
page2.aspx hosts a user control containing a datagrid loaded from xml.
each product in the datagrid links to page3.aspx.
page3.aspx contains a link back to index.aspx

When the datagrid loads 814 rows or less:
index.aspx -> page2.aspx -> click any link -> page3.aspx.
-- Back Button is enabled
-- Going back 1 ( from page3.aspx ) goes back to datagrid and the back
button is still enabled - and the history points to index.

When the datagrid loads 815 rows or more:
index.aspx -> page2.aspx -> click any link -> page3.aspx
-- Back button is enabled.
-- Going back 1 ( from page3.aspx ) goes back to the datagrid and the back
button is no longer enabled. (History is blank - back button grey's out ).

I suppose, the next step would be to reduce the number of columns in the
data set, but I have not taken this step yet. All code is pasted below,
except for the xml doc. I can post the xml separately, or email - your
preference. Thanks for your help!

--DCarroll

**BEGIN CODE**

--index.aspx--

<%@ Page language="c#" Codebehind="index.aspx.cs" AutoEventWireup="false"
Inherits="UserControlTest.index" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Index</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:LinkButton id="LinkButton1" style="Z-INDEX: 101; LEFT: 88px;
POSITION: absolute; TOP: 104px"
runat="server">Page 2 Alerts.xml</asp:LinkButton>
<asp:LinkButton id="LinkButton2" style="Z-INDEX: 102; LEFT: 120px;
POSITION: absolute; TOP: 184px"
runat="server">Page 2 Alert_.xml</asp:LinkButton>
</form>
</body>
</HTML>

--index.aspx.cs--

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace UserControlTest
{
/// <summary>
/// Summary description for index.
/// </summary>
public class index : System.Web.UI.Page
{
protected System.Web.UI.WebControls.LinkButton LinkButton2;
protected System.Web.UI.WebControls.LinkButton LinkButton1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void LinkButton1_Click(object sender, System.EventArgs e)
{
Session["XMLPath"] = @"c:\inetpub\wwwroot\usercontroltest\alerts.xml";
Response.Redirect( "page2.aspx" );
}

private void LinkButton2_Click(object sender, System.EventArgs e)
{
Session["XMLPath"] = @"c:\inetpub\wwwroot\usercontroltest\alert_.xml";
Response.Redirect( "page2.aspx" );
}
}
}

--page2.aspx--
<%@ Page language="c#" Codebehind="page2.aspx.cs" AutoEventWireup="false"
Inherits="UserControlTest.page2" %>
<%@ Register TagPrefix="uc2" TagName="AlertsDataGrid"
Src="AlertsDataGrid.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<html>
<head>
<title>Page2</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">
<uc2:AlertsDataGrid id="dgAlerts" width="100%"
runat="server"></uc2:AlertsDataGrid>
</form>

</body>
</html>

--page2.aspx.cs--
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace UserControlTest
{
/// <summary>
/// Summary description for page3.
/// </summary>
public class page2 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}

--page3.aspx--
<%@ Page language="c#" Codebehind="page3.aspx.cs" AutoEventWireup="false"
Inherits="UserControlTest.page3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Page3</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:HyperLink id="HyperLink1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
absolute; TOP: 112px"
runat="server" NavigateUrl="index.aspx">index</asp:HyperLink>
</form>
</body>
</HTML>

--page3.aspx.cs--
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace UserControlTest
{
/// <summary>
/// Summary description for page3.
/// </summary>
public class page3 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.HyperLink HyperLink1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}

--AlertsDataGrid.ascx--
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="AlertsDataGrid.ascx.cs" Inherits="MarketView.AlertsDataGrid"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<asp:datagrid id="dgMain" runat="server" Width="100%"
AutoGenerateColumns="False" AllowSorting="True">
<Columns>
<asp:BoundColumn DataField="PublishDate" SortExpression="PublishDate"
HeaderText="Publish Date"></asp:BoundColumn>
<asp:ButtonColumn DataTextField="Product" SortExpression="Product"
CommandName="Select" HeaderText="Name"></asp:ButtonColumn>
<asp:BoundColumn DataField="ProductType"
SortExpression="ProductType"></asp:BoundColumn>
<asp:BoundColumn DataField="Provider"
SortExpression="Provider"></asp:BoundColumn>
<asp:BoundColumn DataField="ServiceCategory"
SortExpression="ServiceCategory"></asp:BoundColumn>
<asp:BoundColumn DataField="MarketSegment"
SortExpression="MarketSegment"></asp:BoundColumn>
<asp:BoundColumn DataField="MSA" SortExpression="MSA"></asp:BoundColumn>
<asp:BoundColumn DataField="State" SortExpression="State"></asp:BoundColumn>
<asp:BoundColumn DataField="AlertType"
SortExpression="AlertType"></asp:BoundColumn>
<asp:BoundColumn DataField="ResourceId" SortExpression="ResourceId"
Visible="False"></asp:BoundColumn>
</Columns>
</asp:datagrid>

--AlertsDataGrid.ascs.cs--
namespace MarketView
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using MarketView.Reporting;

/// <summary>
/// Summary description for AlertsDataGrid.
/// </summary>
public class AlertsDataGrid : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DataGrid dgMain;

private DataSet m_dsAlerts;

private void Page_Load(object sender, System.EventArgs e)
{
SetupAlertsDG( dgMain );

if( !this.IsPostBack )
{
DisplayAlerts( );
}
}

private void DisplayAlerts( )
{
m_dsAlerts = CreateAlertsDS();

PopulateAlertsDS( m_dsAlerts );

dgMain.DataSource = m_dsAlerts;
dgMain.DataMember = "Alerts";
dgMain.DataKeyField = "Id";
dgMain.DataBind();
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgMain.ItemCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgMain_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion

private void SetupAlertsDG( DataGrid dg )
{
dg.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
string [] headerText = new string []
{
"Publish Date",
"Name",
"Product Type",
"Provider",
"Service",
"Market Segment",
"Metro Area",
"State",
"Alert Type",
"ResourceId"
};
for( int i = 0; i < dg.Columns.Count; i++ )
{
dg.Columns.HeaderText = headerText;
}
}

private DataSet CreateAlertsDS()
{
DataSet dsAlerts = new DataSet( "dsAlerts" );
DataTable dtAlerts = new DataTable( "Alerts" );
dtAlerts.Columns.Add( "Id", System.Type.GetType( "System.Int32" ) );
dtAlerts.Columns.Add( "Product", System.Type.GetType( "System.String" ) );
dtAlerts.Columns.Add( "ProductType", System.Type.GetType( "System.String"
) );
dtAlerts.Columns.Add( "Provider", System.Type.GetType( "System.String" ) );
dtAlerts.Columns.Add( "ServiceCategory", System.Type.GetType(
"System.String" ) );
dtAlerts.Columns.Add( "MarketSegment", System.Type.GetType(
"System.String" ) );
dtAlerts.Columns.Add( "MSA", System.Type.GetType( "System.String" ) );
dtAlerts.Columns.Add( "State", System.Type.GetType( "System.String" ) );
dtAlerts.Columns.Add( "AlertType", System.Type.GetType( "System.String" )
);
dtAlerts.Columns.Add( "PublishDate", System.Type.GetType( "System.String"
) );
dtAlerts.Columns.Add( "ProductId", System.Type.GetType( "System.Int32" ) );
dtAlerts.Columns.Add( "AlertComments", System.Type.GetType(
"System.String" ) );
dtAlerts.Columns.Add( "ResourceId", System.Type.GetType( "System.Int32" )
);
dsAlerts.Tables.Add( dtAlerts );

return dsAlerts;
}

private void PopulateAlertsDS( DataSet dsAlerts )
{
if( Session[ "XMLPath" ].ToString() != null )
dsAlerts.ReadXml( Session[ "XMLPath" ].ToString() );
}

private void AddRow( DataTable tbl, Alert alert )
{
object [] alertValues = new object[13];
int idx = 0;
alertValues[idx++] = alert.Id;
alertValues[idx++] = alert.Product;
alertValues[idx++] = alert.ProductType;
alertValues[idx++] = alert.Provider;
alertValues[idx++] = alert.ServiceCategory;
alertValues[idx++] = alert.MarketSegment;
alertValues[idx++] = alert.MSA;
alertValues[idx++] = alert.State;
alertValues[idx++] = alert.AlertType;
alertValues[idx++] = alert.PublishDate;
alertValues[idx++] = alert.ProductId;
alertValues[idx++] = alert.AlertComment;
alertValues[idx] = alert.ResourceId;
tbl.Rows.Add( alertValues );
}

private void dgMain_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if( e.CommandName.Equals( "Select" ) )
{
Response.Redirect( "page3.aspx" );
}
}
}
}

**END CODE**
 
S

Steven Cheng[MSFT]

Thanks for your response DCarroll,

Seems really strange. I think the 815 rows on your side may also be
environment specific so that I may unable to reproduce the problem through
the same value. Anyway, I'll follow the DataTable structure you described
and performed some local test accordingly. I'll update you soon.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




--------------------
| Thread-Topic: Response.Redirect from within a user control affects
browser h
| thread-index: AcXAUUs3ki8qarrZRbaenVm/qzYr1w==
| X-WBNR-Posting-Host: 198.6.95.95
| From: "=?Utf-8?B?RENhcnJvbGw=?=" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: Response.Redirect from within a user control affects browser
h
| Date: Fri, 23 Sep 2005 08:13:03 -0700
| Lines: 451
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:4236
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| Steven,
| Thanks for your quick response. I've been doing some further testing,
and
| have some results and some sample code for you. The problem seems to be
| related to the number of row in the datagrid being displayed. I'm
pasting
| code at the bottom of this post, but not data. The xml doc feeding this
gets
| a little large - I can post it if you like, or can you email me directly
and
| I can reply with the xml doc?
|
| Quick review of my testing/results:
|
| index.aspx has a link to page2.aspx.
| page2.aspx hosts a user control containing a datagrid loaded from xml.
| each product in the datagrid links to page3.aspx.
| page3.aspx contains a link back to index.aspx
|
| When the datagrid loads 814 rows or less:
| index.aspx -> page2.aspx -> click any link -> page3.aspx.
| -- Back Button is enabled
| -- Going back 1 ( from page3.aspx ) goes back to datagrid and the back
| button is still enabled - and the history points to index.
|
| When the datagrid loads 815 rows or more:
| index.aspx -> page2.aspx -> click any link -> page3.aspx
| -- Back button is enabled.
| -- Going back 1 ( from page3.aspx ) goes back to the datagrid and the
back
| button is no longer enabled. (History is blank - back button grey's out
).
|
| I suppose, the next step would be to reduce the number of columns in the
| data set, but I have not taken this step yet. All code is pasted below,
| except for the xml doc. I can post the xml separately, or email - your
| preference. Thanks for your help!
|
| --DCarroll
|
| **BEGIN CODE**
|
| --index.aspx--
|
| <%@ Page language="c#" Codebehind="index.aspx.cs" AutoEventWireup="false"
| Inherits="UserControlTest.index" %>
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
| <HTML>
| <HEAD>
| <title>Index</title>
| <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
| <meta name="CODE_LANGUAGE" Content="C#">
| <meta name="vs_defaultClientScript" content="JavaScript">
| <meta name="vs_targetSchema"
| content="http://schemas.microsoft.com/intellisense/ie5">
| </HEAD>
| <body MS_POSITIONING="GridLayout">
| <form id="Form1" method="post" runat="server">
| <asp:LinkButton id="LinkButton1" style="Z-INDEX: 101; LEFT: 88px;
| POSITION: absolute; TOP: 104px"
| runat="server">Page 2 Alerts.xml</asp:LinkButton>
| <asp:LinkButton id="LinkButton2" style="Z-INDEX: 102; LEFT: 120px;
| POSITION: absolute; TOP: 184px"
| runat="server">Page 2 Alert_.xml</asp:LinkButton>
| </form>
| </body>
| </HTML>
|
| --index.aspx.cs--
|
| using System;
| using System.Collections;
| using System.ComponentModel;
| using System.Data;
| using System.Drawing;
| using System.Web;
| using System.Web.SessionState;
| using System.Web.UI;
| using System.Web.UI.WebControls;
| using System.Web.UI.HtmlControls;
|
| namespace UserControlTest
| {
| /// <summary>
| /// Summary description for index.
| /// </summary>
| public class index : System.Web.UI.Page
| {
| protected System.Web.UI.WebControls.LinkButton LinkButton2;
| protected System.Web.UI.WebControls.LinkButton LinkButton1;
|
| private void Page_Load(object sender, System.EventArgs e)
| {
| // Put user code to initialize the page here
| }
|
| #region Web Form Designer generated code
| override protected void OnInit(EventArgs e)
| {
| //
| // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| //
| InitializeComponent();
| base.OnInit(e);
| }
|
| /// <summary>
| /// Required method for Designer support - do not modify
| /// the contents of this method with the code editor.
| /// </summary>
| private void InitializeComponent()
| {
| this.LinkButton1.Click += new
System.EventHandler(this.LinkButton1_Click);
| this.LinkButton2.Click += new
System.EventHandler(this.LinkButton2_Click);
| this.Load += new System.EventHandler(this.Page_Load);
|
| }
| #endregion
|
| private void LinkButton1_Click(object sender, System.EventArgs e)
| {
| Session["XMLPath"] = @"c:\inetpub\wwwroot\usercontroltest\alerts.xml";
| Response.Redirect( "page2.aspx" );
| }
|
| private void LinkButton2_Click(object sender, System.EventArgs e)
| {
| Session["XMLPath"] = @"c:\inetpub\wwwroot\usercontroltest\alert_.xml";
| Response.Redirect( "page2.aspx" );
| }
| }
| }
|
| --page2.aspx--
| <%@ Page language="c#" Codebehind="page2.aspx.cs" AutoEventWireup="false"
| Inherits="UserControlTest.page2" %>
| <%@ Register TagPrefix="uc2" TagName="AlertsDataGrid"
| Src="AlertsDataGrid.ascx" %>
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
|
| <html>
| <head>
| <title>Page2</title>
| <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
| <meta name="CODE_LANGUAGE" Content="C#">
| <meta name=vs_defaultClientScript content="JavaScript">
| <meta name=vs_targetSchema
| content="http://schemas.microsoft.com/intellisense/ie5">
| </head>
| <body MS_POSITIONING="GridLayout">
|
| <form id="Form1" method="post" runat="server">
| <uc2:AlertsDataGrid id="dgAlerts" width="100%"
| runat="server"></uc2:AlertsDataGrid>
| </form>
|
| </body>
| </html>
|
| --page2.aspx.cs--
| using System;
| using System.Collections;
| using System.ComponentModel;
| using System.Data;
| using System.Drawing;
| using System.Web;
| using System.Web.SessionState;
| using System.Web.UI;
| using System.Web.UI.WebControls;
| using System.Web.UI.HtmlControls;
|
| namespace UserControlTest
| {
| /// <summary>
| /// Summary description for page3.
| /// </summary>
| public class page2 : System.Web.UI.Page
| {
| private void Page_Load(object sender, System.EventArgs e)
| {
| // Put user code to initialize the page here
| }
|
| #region Web Form Designer generated code
| override protected void OnInit(EventArgs e)
| {
| //
| // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| //
| InitializeComponent();
| base.OnInit(e);
| }
|
| /// <summary>
| /// Required method for Designer support - do not modify
| /// the contents of this method with the code editor.
| /// </summary>
| private void InitializeComponent()
| {
| this.Load += new System.EventHandler(this.Page_Load);
| }
| #endregion
| }
| }
|
| --page3.aspx--
| <%@ Page language="c#" Codebehind="page3.aspx.cs" AutoEventWireup="false"
| Inherits="UserControlTest.page3" %>
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
| <HTML>
| <HEAD>
| <title>Page3</title>
| <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
| <meta name="CODE_LANGUAGE" Content="C#">
| <meta name="vs_defaultClientScript" content="JavaScript">
| <meta name="vs_targetSchema"
| content="http://schemas.microsoft.com/intellisense/ie5">
| </HEAD>
| <body MS_POSITIONING="GridLayout">
| <form id="Form1" method="post" runat="server">
| <asp:HyperLink id="HyperLink1" style="Z-INDEX: 101; LEFT: 96px;
POSITION:
| absolute; TOP: 112px"
| runat="server" NavigateUrl="index.aspx">index</asp:HyperLink>
| </form>
| </body>
| </HTML>
|
| --page3.aspx.cs--
| using System;
| using System.Collections;
| using System.ComponentModel;
| using System.Data;
| using System.Drawing;
| using System.Web;
| using System.Web.SessionState;
| using System.Web.UI;
| using System.Web.UI.WebControls;
| using System.Web.UI.HtmlControls;
|
| namespace UserControlTest
| {
| /// <summary>
| /// Summary description for page3.
| /// </summary>
| public class page3 : System.Web.UI.Page
| {
| protected System.Web.UI.WebControls.HyperLink HyperLink1;
|
| private void Page_Load(object sender, System.EventArgs e)
| {
| // Put user code to initialize the page here
| }
|
| #region Web Form Designer generated code
| override protected void OnInit(EventArgs e)
| {
| //
| // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| //
| InitializeComponent();
| base.OnInit(e);
| }
|
| /// <summary>
| /// Required method for Designer support - do not modify
| /// the contents of this method with the code editor.
| /// </summary>
| private void InitializeComponent()
| {
| this.Load += new System.EventHandler(this.Page_Load);
|
| }
| #endregion
| }
| }
|
| --AlertsDataGrid.ascx--
| <%@ Control Language="c#" AutoEventWireup="false"
| Codebehind="AlertsDataGrid.ascx.cs" Inherits="MarketView.AlertsDataGrid"
| TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
| <asp:datagrid id="dgMain" runat="server" Width="100%"
| AutoGenerateColumns="False" AllowSorting="True">
| <Columns>
| <asp:BoundColumn DataField="PublishDate" SortExpression="PublishDate"
| HeaderText="Publish Date"></asp:BoundColumn>
| <asp:ButtonColumn DataTextField="Product" SortExpression="Product"
| CommandName="Select" HeaderText="Name"></asp:ButtonColumn>
| <asp:BoundColumn DataField="ProductType"
| SortExpression="ProductType"></asp:BoundColumn>
| <asp:BoundColumn DataField="Provider"
| SortExpression="Provider"></asp:BoundColumn>
| <asp:BoundColumn DataField="ServiceCategory"
| SortExpression="ServiceCategory"></asp:BoundColumn>
| <asp:BoundColumn DataField="MarketSegment"
| SortExpression="MarketSegment"></asp:BoundColumn>
| <asp:BoundColumn DataField="MSA" SortExpression="MSA"></asp:BoundColumn>
| <asp:BoundColumn DataField="State"
SortExpression="State"></asp:BoundColumn>
| <asp:BoundColumn DataField="AlertType"
| SortExpression="AlertType"></asp:BoundColumn>
| <asp:BoundColumn DataField="ResourceId" SortExpression="ResourceId"
| Visible="False"></asp:BoundColumn>
| </Columns>
| </asp:datagrid>
|
| --AlertsDataGrid.ascs.cs--
| namespace MarketView
| {
| using System;
| using System.Data;
| using System.Drawing;
| using System.Web;
| using System.Web.UI.WebControls;
| using System.Web.UI.HtmlControls;
| using MarketView.Reporting;
|
| /// <summary>
| /// Summary description for AlertsDataGrid.
| /// </summary>
| public class AlertsDataGrid : System.Web.UI.UserControl
| {
| protected System.Web.UI.WebControls.DataGrid dgMain;
|
| private DataSet m_dsAlerts;
|
| private void Page_Load(object sender, System.EventArgs e)
| {
| SetupAlertsDG( dgMain );
|
| if( !this.IsPostBack )
| {
| DisplayAlerts( );
| }
| }
|
| private void DisplayAlerts( )
| {
| m_dsAlerts = CreateAlertsDS();
|
| PopulateAlertsDS( m_dsAlerts );
|
| dgMain.DataSource = m_dsAlerts;
| dgMain.DataMember = "Alerts";
| dgMain.DataKeyField = "Id";
| dgMain.DataBind();
| }
|
| #region Web Form Designer generated code
| override protected void OnInit(EventArgs e)
| {
| //
| // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| //
| InitializeComponent();
| base.OnInit(e);
| }
|
| /// <summary>
| /// Required method for Designer support - do not modify
| /// the contents of this method with the code editor.
| /// </summary>
| private void InitializeComponent()
| {
| this.dgMain.ItemCommand += new
|
System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgMain_ItemComman
d);
| this.Load += new System.EventHandler(this.Page_Load);
| }
| #endregion
|
| private void SetupAlertsDG( DataGrid dg )
| {
| dg.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
| string [] headerText = new string []
| {
| "Publish Date",
| "Name",
| "Product Type",
| "Provider",
| "Service",
| "Market Segment",
| "Metro Area",
| "State",
| "Alert Type",
| "ResourceId"
| };
| for( int i = 0; i < dg.Columns.Count; i++ )
| {
| dg.Columns.HeaderText = headerText;
| }
| }
|
| private DataSet CreateAlertsDS()
| {
| DataSet dsAlerts = new DataSet( "dsAlerts" );
| DataTable dtAlerts = new DataTable( "Alerts" );
| dtAlerts.Columns.Add( "Id", System.Type.GetType( "System.Int32" ) );
| dtAlerts.Columns.Add( "Product", System.Type.GetType( "System.String"
) );
| dtAlerts.Columns.Add( "ProductType", System.Type.GetType(
"System.String"
| ) );
| dtAlerts.Columns.Add( "Provider", System.Type.GetType( "System.String"
) );
| dtAlerts.Columns.Add( "ServiceCategory", System.Type.GetType(
| "System.String" ) );
| dtAlerts.Columns.Add( "MarketSegment", System.Type.GetType(
| "System.String" ) );
| dtAlerts.Columns.Add( "MSA", System.Type.GetType( "System.String" ) );
| dtAlerts.Columns.Add( "State", System.Type.GetType( "System.String" )
);
| dtAlerts.Columns.Add( "AlertType", System.Type.GetType(
"System.String" )
| );
| dtAlerts.Columns.Add( "PublishDate", System.Type.GetType(
"System.String"
| ) );
| dtAlerts.Columns.Add( "ProductId", System.Type.GetType( "System.Int32"
) );
| dtAlerts.Columns.Add( "AlertComments", System.Type.GetType(
| "System.String" ) );
| dtAlerts.Columns.Add( "ResourceId", System.Type.GetType(
"System.Int32" )
| );
| dsAlerts.Tables.Add( dtAlerts );
|
| return dsAlerts;
| }
|
| private void PopulateAlertsDS( DataSet dsAlerts )
| {
| if( Session[ "XMLPath" ].ToString() != null )
| dsAlerts.ReadXml( Session[ "XMLPath" ].ToString() );
| }
|
| private void AddRow( DataTable tbl, Alert alert )
| {
| object [] alertValues = new object[13];
| int idx = 0;
| alertValues[idx++] = alert.Id;
| alertValues[idx++] = alert.Product;
| alertValues[idx++] = alert.ProductType;
| alertValues[idx++] = alert.Provider;
| alertValues[idx++] = alert.ServiceCategory;
| alertValues[idx++] = alert.MarketSegment;
| alertValues[idx++] = alert.MSA;
| alertValues[idx++] = alert.State;
| alertValues[idx++] = alert.AlertType;
| alertValues[idx++] = alert.PublishDate;
| alertValues[idx++] = alert.ProductId;
| alertValues[idx++] = alert.AlertComment;
| alertValues[idx] = alert.ResourceId;
| tbl.Rows.Add( alertValues );
| }
|
| private void dgMain_ItemCommand(object source,
| System.Web.UI.WebControls.DataGridCommandEventArgs e)
| {
| if( e.CommandName.Equals( "Select" ) )
| {
| Response.Redirect( "page3.aspx" );
| }
| }
| }
| }
|
| **END CODE**
|
 
S

Steven Cheng[MSFT]

Hi DCarroll,

Sorry for keep you waiting. After some further research, I've got
everything clear on this issue. Yes, as I've expected in the previous
message, this is a limitation of the IE webbrowser on the history page's
caching. As for those pages(should call them a temp view) in the history
list, the browser will cache those form element's value in the clietnside's
memory. And IE has a default limitation of such cached data (be default
arround 1m ...). However, for ASP.NET web page, when using templdata
databinding contro( a large datagrid)l , there'll output large viewstate
which is serilized in the "__VIEWSTAT" input hidden field, that cause the
cached data's size exceed the clientside IE's memory limit then the former
cached item be removed. Currently, for this problem, we have the
following two approachs:

1. For asp.net web application, try limit our webpage's size(especially the
ViewState size) so as to avoid output too match data which will consume
huge clientside caching memory.

2. For the IE, we can use the following registry value to adjust the cache
limit:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\TravelLog

the TraveILog need to be created manually. Then, add a DWORD value named
"MaxSize" under it,
set it's value to more than 1Mb( in bytes), e.g. 10mb = 0xA00000

Anyway, I think this limit is designed from a securirty perspective since
we don't want the browser's client caching consume too much of the user
machine's total memory. Not sure whether other browsers has also taked
care of such potential memory issue.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




--------------------
| X-Tomcat-ID: 94492275
| References: <[email protected]>
<[email protected]>
<[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Mon, 26 Sep 2005 07:04:54 GMT
| Subject: RE: Response.Redirect from within a user control affects browser
h
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| Lines: 412
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:4246
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Thanks for your response DCarroll,
|
| Seems really strange. I think the 815 rows on your side may also be
| environment specific so that I may unable to reproduce the problem
through
| the same value. Anyway, I'll follow the DataTable structure you described
| and performed some local test accordingly. I'll update you soon.
|
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
|
| --------------------
| | Thread-Topic: Response.Redirect from within a user control affects
| browser h
| | thread-index: AcXAUUs3ki8qarrZRbaenVm/qzYr1w==
| | X-WBNR-Posting-Host: 198.6.95.95
| | From: "=?Utf-8?B?RENhcnJvbGw=?=" <[email protected]>
| | References: <[email protected]>
| <[email protected]>
| | Subject: RE: Response.Redirect from within a user control affects
browser
| h
| | Date: Fri, 23 Sep 2005 08:13:03 -0700
| | Lines: 451
| | Message-ID: <[email protected]>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | charset="Utf-8"
| | Content-Transfer-Encoding: 7bit
| | X-Newsreader: Microsoft CDO for Windows 2000
| | Content-Class: urn:content-classes:message
| | Importance: normal
| | Priority: normal
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| | Xref: TK2MSFTNGXA01.phx.gbl
| microsoft.public.dotnet.framework.aspnet.buildingcontrols:4236
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| |
| | Steven,
| | Thanks for your quick response. I've been doing some further
testing,
| and
| | have some results and some sample code for you. The problem seems to
be
| | related to the number of row in the datagrid being displayed. I'm
| pasting
| | code at the bottom of this post, but not data. The xml doc feeding
this
| gets
| | a little large - I can post it if you like, or can you email me
directly
| and
| | I can reply with the xml doc?
| |
| | Quick review of my testing/results:
| |
| | index.aspx has a link to page2.aspx.
| | page2.aspx hosts a user control containing a datagrid loaded from xml.
| | each product in the datagrid links to page3.aspx.
| | page3.aspx contains a link back to index.aspx
| |
| | When the datagrid loads 814 rows or less:
| | index.aspx -> page2.aspx -> click any link -> page3.aspx.
| | -- Back Button is enabled
| | -- Going back 1 ( from page3.aspx ) goes back to datagrid and the
back
| | button is still enabled - and the history points to index.
| |
| | When the datagrid loads 815 rows or more:
| | index.aspx -> page2.aspx -> click any link -> page3.aspx
| | -- Back button is enabled.
| | -- Going back 1 ( from page3.aspx ) goes back to the datagrid and the
| back
| | button is no longer enabled. (History is blank - back button grey's
out
| ).
| |
| | I suppose, the next step would be to reduce the number of columns in
the
| | data set, but I have not taken this step yet. All code is pasted
below,
| | except for the xml doc. I can post the xml separately, or email - your
| | preference. Thanks for your help!
| |
| | --DCarroll
| |
| | **BEGIN CODE**
| |
| | --index.aspx--
| |
| | <%@ Page language="c#" Codebehind="index.aspx.cs"
AutoEventWireup="false"
| | Inherits="UserControlTest.index" %>
| | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
| | <HTML>
| | <HEAD>
| | <title>Index</title>
| | <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
| | <meta name="CODE_LANGUAGE" Content="C#">
| | <meta name="vs_defaultClientScript" content="JavaScript">
| | <meta name="vs_targetSchema"
| | content="http://schemas.microsoft.com/intellisense/ie5">
| | </HEAD>
| | <body MS_POSITIONING="GridLayout">
| | <form id="Form1" method="post" runat="server">
| | <asp:LinkButton id="LinkButton1" style="Z-INDEX: 101; LEFT: 88px;
| | POSITION: absolute; TOP: 104px"
| | runat="server">Page 2 Alerts.xml</asp:LinkButton>
| | <asp:LinkButton id="LinkButton2" style="Z-INDEX: 102; LEFT: 120px;
| | POSITION: absolute; TOP: 184px"
| | runat="server">Page 2 Alert_.xml</asp:LinkButton>
| | </form>
| | </body>
| | </HTML>
| |
| | --index.aspx.cs--
| |
| | using System;
| | using System.Collections;
| | using System.ComponentModel;
| | using System.Data;
| | using System.Drawing;
| | using System.Web;
| | using System.Web.SessionState;
| | using System.Web.UI;
| | using System.Web.UI.WebControls;
| | using System.Web.UI.HtmlControls;
| |
| | namespace UserControlTest
| | {
| | /// <summary>
| | /// Summary description for index.
| | /// </summary>
| | public class index : System.Web.UI.Page
| | {
| | protected System.Web.UI.WebControls.LinkButton LinkButton2;
| | protected System.Web.UI.WebControls.LinkButton LinkButton1;
| |
| | private void Page_Load(object sender, System.EventArgs e)
| | {
| | // Put user code to initialize the page here
| | }
| |
| | #region Web Form Designer generated code
| | override protected void OnInit(EventArgs e)
| | {
| | //
| | // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| | //
| | InitializeComponent();
| | base.OnInit(e);
| | }
| |
| | /// <summary>
| | /// Required method for Designer support - do not modify
| | /// the contents of this method with the code editor.
| | /// </summary>
| | private void InitializeComponent()
| | {
| | this.LinkButton1.Click += new
| System.EventHandler(this.LinkButton1_Click);
| | this.LinkButton2.Click += new
| System.EventHandler(this.LinkButton2_Click);
| | this.Load += new System.EventHandler(this.Page_Load);
| |
| | }
| | #endregion
| |
| | private void LinkButton1_Click(object sender, System.EventArgs e)
| | {
| | Session["XMLPath"] =
@"c:\inetpub\wwwroot\usercontroltest\alerts.xml";
| | Response.Redirect( "page2.aspx" );
| | }
| |
| | private void LinkButton2_Click(object sender, System.EventArgs e)
| | {
| | Session["XMLPath"] =
@"c:\inetpub\wwwroot\usercontroltest\alert_.xml";
| | Response.Redirect( "page2.aspx" );
| | }
| | }
| | }
| |
| | --page2.aspx--
| | <%@ Page language="c#" Codebehind="page2.aspx.cs"
AutoEventWireup="false"
| | Inherits="UserControlTest.page2" %>
| | <%@ Register TagPrefix="uc2" TagName="AlertsDataGrid"
| | Src="AlertsDataGrid.ascx" %>
| | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
| |
| | <html>
| | <head>
| | <title>Page2</title>
| | <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
| | <meta name="CODE_LANGUAGE" Content="C#">
| | <meta name=vs_defaultClientScript content="JavaScript">
| | <meta name=vs_targetSchema
| | content="http://schemas.microsoft.com/intellisense/ie5">
| | </head>
| | <body MS_POSITIONING="GridLayout">
| |
| | <form id="Form1" method="post" runat="server">
| | <uc2:AlertsDataGrid id="dgAlerts" width="100%"
| | runat="server"></uc2:AlertsDataGrid>
| | </form>
| |
| | </body>
| | </html>
| |
| | --page2.aspx.cs--
| | using System;
| | using System.Collections;
| | using System.ComponentModel;
| | using System.Data;
| | using System.Drawing;
| | using System.Web;
| | using System.Web.SessionState;
| | using System.Web.UI;
| | using System.Web.UI.WebControls;
| | using System.Web.UI.HtmlControls;
| |
| | namespace UserControlTest
| | {
| | /// <summary>
| | /// Summary description for page3.
| | /// </summary>
| | public class page2 : System.Web.UI.Page
| | {
| | private void Page_Load(object sender, System.EventArgs e)
| | {
| | // Put user code to initialize the page here
| | }
| |
| | #region Web Form Designer generated code
| | override protected void OnInit(EventArgs e)
| | {
| | //
| | // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| | //
| | InitializeComponent();
| | base.OnInit(e);
| | }
| |
| | /// <summary>
| | /// Required method for Designer support - do not modify
| | /// the contents of this method with the code editor.
| | /// </summary>
| | private void InitializeComponent()
| | {
| | this.Load += new System.EventHandler(this.Page_Load);
| | }
| | #endregion
| | }
| | }
| |
| | --page3.aspx--
| | <%@ Page language="c#" Codebehind="page3.aspx.cs"
AutoEventWireup="false"
| | Inherits="UserControlTest.page3" %>
| | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
| | <HTML>
| | <HEAD>
| | <title>Page3</title>
| | <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
| | <meta name="CODE_LANGUAGE" Content="C#">
| | <meta name="vs_defaultClientScript" content="JavaScript">
| | <meta name="vs_targetSchema"
| | content="http://schemas.microsoft.com/intellisense/ie5">
| | </HEAD>
| | <body MS_POSITIONING="GridLayout">
| | <form id="Form1" method="post" runat="server">
| | <asp:HyperLink id="HyperLink1" style="Z-INDEX: 101; LEFT: 96px;
| POSITION:
| | absolute; TOP: 112px"
| | runat="server" NavigateUrl="index.aspx">index</asp:HyperLink>
| | </form>
| | </body>
| | </HTML>
| |
| | --page3.aspx.cs--
| | using System;
| | using System.Collections;
| | using System.ComponentModel;
| | using System.Data;
| | using System.Drawing;
| | using System.Web;
| | using System.Web.SessionState;
| | using System.Web.UI;
| | using System.Web.UI.WebControls;
| | using System.Web.UI.HtmlControls;
| |
| | namespace UserControlTest
| | {
| | /// <summary>
| | /// Summary description for page3.
| | /// </summary>
| | public class page3 : System.Web.UI.Page
| | {
| | protected System.Web.UI.WebControls.HyperLink HyperLink1;
| |
| | private void Page_Load(object sender, System.EventArgs e)
| | {
| | // Put user code to initialize the page here
| | }
| |
| | #region Web Form Designer generated code
| | override protected void OnInit(EventArgs e)
| | {
| | //
| | // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| | //
| | InitializeComponent();
| | base.OnInit(e);
| | }
| |
| | /// <summary>
| | /// Required method for Designer support - do not modify
| | /// the contents of this method with the code editor.
| | /// </summary>
| | private void InitializeComponent()
| | {
| | this.Load += new System.EventHandler(this.Page_Load);
| |
| | }
| | #endregion
| | }
| | }
| |
| | --AlertsDataGrid.ascx--
| | <%@ Control Language="c#" AutoEventWireup="false"
| | Codebehind="AlertsDataGrid.ascx.cs"
Inherits="MarketView.AlertsDataGrid"
| | TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
| | <asp:datagrid id="dgMain" runat="server" Width="100%"
| | AutoGenerateColumns="False" AllowSorting="True">
| | <Columns>
| | <asp:BoundColumn DataField="PublishDate" SortExpression="PublishDate"
| | HeaderText="Publish Date"></asp:BoundColumn>
| | <asp:ButtonColumn DataTextField="Product" SortExpression="Product"
| | CommandName="Select" HeaderText="Name"></asp:ButtonColumn>
| | <asp:BoundColumn DataField="ProductType"
| | SortExpression="ProductType"></asp:BoundColumn>
| | <asp:BoundColumn DataField="Provider"
| | SortExpression="Provider"></asp:BoundColumn>
| | <asp:BoundColumn DataField="ServiceCategory"
| | SortExpression="ServiceCategory"></asp:BoundColumn>
| | <asp:BoundColumn DataField="MarketSegment"
| | SortExpression="MarketSegment"></asp:BoundColumn>
| | <asp:BoundColumn DataField="MSA"
SortExpression="MSA"></asp:BoundColumn>
| | <asp:BoundColumn DataField="State"
| SortExpression="State"></asp:BoundColumn>
| | <asp:BoundColumn DataField="AlertType"
| | SortExpression="AlertType"></asp:BoundColumn>
| | <asp:BoundColumn DataField="ResourceId" SortExpression="ResourceId"
| | Visible="False"></asp:BoundColumn>
| | </Columns>
| | </asp:datagrid>
| |
| | --AlertsDataGrid.ascs.cs--
| | namespace MarketView
| | {
| | using System;
| | using System.Data;
| | using System.Drawing;
| | using System.Web;
| | using System.Web.UI.WebControls;
| | using System.Web.UI.HtmlControls;
| | using MarketView.Reporting;
| |
| | /// <summary>
| | /// Summary description for AlertsDataGrid.
| | /// </summary>
| | public class AlertsDataGrid : System.Web.UI.UserControl
| | {
| | protected System.Web.UI.WebControls.DataGrid dgMain;
| |
| | private DataSet m_dsAlerts;
| |
| | private void Page_Load(object sender, System.EventArgs e)
| | {
| | SetupAlertsDG( dgMain );
| |
| | if( !this.IsPostBack )
| | {
| | DisplayAlerts( );
| | }
| | }
| |
| | private void DisplayAlerts( )
| | {
| | m_dsAlerts = CreateAlertsDS();
| |
| | PopulateAlertsDS( m_dsAlerts );
| |
| | dgMain.DataSource = m_dsAlerts;
| | dgMain.DataMember = "Alerts";
| | dgMain.DataKeyField = "Id";
| | dgMain.DataBind();
| | }
| |
| | #region Web Form Designer generated code
| | override protected void OnInit(EventArgs e)
| | {
| | //
| | // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| | //
| | InitializeComponent();
| | base.OnInit(e);
| | }
| |
| | /// <summary>
| | /// Required method for Designer support - do not modify
| | /// the contents of this method with the code editor.
| | /// </summary>
| | private void InitializeComponent()
| | {
| | this.dgMain.ItemCommand += new
| |
|
System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgMain_ItemComman
| d);
| | this.Load += new System.EventHandler(this.Page_Load);
| | }
| | #endregion
| |
| | private void SetupAlertsDG( DataGrid dg )
| | {
| | dg.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
| | string [] headerText = new string []
| | {
| | "Publish Date",
| | "Name",
| | "Product Type",
| | "Provider",
| | "Service",
| | "Market Segment",
| | "Metro Area",
| | "State",
| | "Alert Type",
| | "ResourceId"
| | };
| | for( int i = 0; i < dg.Columns.Count; i++ )
| | {
| | dg.Columns.HeaderText = headerText;
| | }
| | }
| |
| | private DataSet CreateAlertsDS()
| | {
| | DataSet dsAlerts = new DataSet( "dsAlerts" );
| | DataTable dtAlerts = new DataTable( "Alerts" );
| | dtAlerts.Columns.Add( "Id", System.Type.GetType( "System.Int32" ) );
| | dtAlerts.Columns.Add( "Product", System.Type.GetType(
"System.String"
| ) );
| | dtAlerts.Columns.Add( "ProductType", System.Type.GetType(
| "System.String"
| | ) );
| | dtAlerts.Columns.Add( "Provider", System.Type.GetType(
"System.String"
| ) );
| | dtAlerts.Columns.Add( "ServiceCategory", System.Type.GetType(
| | "System.String" ) );
| | dtAlerts.Columns.Add( "MarketSegment", System.Type.GetType(
| | "System.String" ) );
| | dtAlerts.Columns.Add( "MSA", System.Type.GetType( "System.String" )
);
| | dtAlerts.Columns.Add( "State", System.Type.GetType( "System.String"
)
| );
| | dtAlerts.Columns.Add( "AlertType", System.Type.GetType(
| "System.String" )
| | );
| | dtAlerts.Columns.Add( "PublishDate", System.Type.GetType(
| "System.String"
| | ) );
| | dtAlerts.Columns.Add( "ProductId", System.Type.GetType(
"System.Int32"
| ) );
| | dtAlerts.Columns.Add( "AlertComments", System.Type.GetType(
| | "System.String" ) );
| | dtAlerts.Columns.Add( "ResourceId", System.Type.GetType(
| "System.Int32" )
| | );
| | dsAlerts.Tables.Add( dtAlerts );
| |
| | return dsAlerts;
| | }
| |
| | private void PopulateAlertsDS( DataSet dsAlerts )
| | {
| | if( Session[ "XMLPath" ].ToString() != null )
| | dsAlerts.ReadXml( Session[ "XMLPath" ].ToString() );
| | }
| |
| | private void AddRow( DataTable tbl, Alert alert )
| | {
| | object [] alertValues = new object[13];
| | int idx = 0;
| | alertValues[idx++] = alert.Id;
| | alertValues[idx++] = alert.Product;
| | alertValues[idx++] = alert.ProductType;
| | alertValues[idx++] = alert.Provider;
| | alertValues[idx++] = alert.ServiceCategory;
| | alertValues[idx++] = alert.MarketSegment;
| | alertValues[idx++] = alert.MSA;
| | alertValues[idx++] = alert.State;
| | alertValues[idx++] = alert.AlertType;
| | alertValues[idx++] = alert.PublishDate;
| | alertValues[idx++] = alert.ProductId;
| | alertValues[idx++] = alert.AlertComment;
| | alertValues[idx] = alert.ResourceId;
| | tbl.Rows.Add( alertValues );
| | }
| |
| | private void dgMain_ItemCommand(object source,
| | System.Web.UI.WebControls.DataGridCommandEventArgs e)
| | {
| | if( e.CommandName.Equals( "Select" ) )
| | {
| | Response.Redirect( "page3.aspx" );
| | }
| | }
| | }
| | }
| |
| | **END CODE**
| |
|
|
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top