ASPX Page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PostbackProblem.aspx.cs" Inherits="Cresent.WorkSafeExt.GraphicalPlanner.PostbackProblem" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="RMGPA" runat="server" />
<asp:ScriptManager ID="SMUpate" runat="server" />
<ext:Store ID="StrALEMaps" runat="server"><Model><ext:Model ID="mdALEMaps" runat="server"><Fields><ext:ModelField Name="MapType" Type="Int" /><ext:ModelField Name="MapID" Type="Int" /><ext:ModelField Name="Description" Type="String" /><ext:ModelField Name="X" Type="Int" /><ext:ModelField Name="Y" Type="Int" /><ext:ModelField Name="isActive" Type="Boolean" /></Fields></ext:Model></Model></ext:Store><ext:Panel ID="pnlGPACenters" runat="server" Region="Center" Border="true" Title="Graphical Planner" ButtonAlign="Left">
<Items>
<ext:Panel ID="MainPanel" runat="server" Collapsible="true" Height="400" BodyPadding="30"><Content>
<asp:UpdatePanel ID="upImageMainMap" runat="server"><ContentTemplate><asp:Panel ID="pnl1" runat="server">
<asp:ImageButton ID="ImageMainMap" OnClick="ImageMainMap_Click" runat="server" Height="50" ImageUrl="~/Images/heroAccent.png" AlternateText="Image " /></asp:Panel></ContentTemplate></asp:UpdatePanel></Content></ext:Panel>
<ext:Panel ID="PanelMapAreasLocationsEquitpments" runat="server" Layout="FitLayout" Height="400" ButtonAlign="Left" Collapsible="true">
<Items>
<ext:GridPanel ID="gpALE" runat="server" StoreID="StrALEMaps" Border="false" AutoScroll="true">
<ColumnModel ID="ctl512">
<Columns>
<ext:Column ID="ColMapID" runat="server" Text="MapID" DataIndex="MapID" Width="150" />
<ext:Column ID="ColMapType" runat="server" Text="MapType" DataIndex="MapType" Width="200" />
<ext:Column ID="ColDescription" runat="server" Text="Description" DataIndex="Description" Width="200" />
<ext:Column ID="ColX" runat="server" Text="X" DataIndex="X" Width="150" />
<ext:Column ID="ColY" runat="server" Text="Y" DataIndex="Y" Width="150" />
<ext:CheckColumn ID="IsActive" runat="server" DataIndex="isActive" Text="Is Active" Width="150" />
</Columns>
</ColumnModel>
<View><ext:GridView ID="gpAreaMappings" runat="server" LoadMask="true" /></View>
<SelectionModel>
<ext:RowSelectionModel ID="rsmGraphicalPlannerAdmin" runat="server" Mode="Single" />
</SelectionModel>
</ext:GridPanel>
</Items></ext:Panel></Items></ext:Panel>
</form>
</body>
</html>
Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
namespace Cresent.WorkSafeExt.GraphicalPlanner
{
public partial class PostbackProblem : System.Web.UI.Page
{
protected List<MapPoints> listPoints
{
set
{
Session["Points"] = value;
}
get
{
if (Session["Points"] == null)
return new List<MapPoints>();
else
return ((List<MapPoints>)Session["Points"]);
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest && !Page.IsPostBack)
{
this.listPoints = new List<MapPoints>
{
new MapPoints{ MapType=1,MapID=2,Description="test1",X=347,Y=542,isActive=true},
new MapPoints{ MapType=2,MapID=8,Description="test2",X=348,Y=543,isActive=true},
new MapPoints{ MapType=3,MapID=7,Description="test3",X=346,Y=544,isActive=true},
new MapPoints{ MapType=4,MapID=8,Description="test4",X=344,Y=545,isActive=true},
new MapPoints{ MapType=5,MapID=6,Description="test5",X=342,Y=546,isActive=true},
};
BindStore();
}
}
protected void ImageMainMap_Click(object sender, ImageClickEventArgs e)
{
MapPoints obj = new MapPoints { MapType = 6, MapID = 6, Description = "test6", X = 442, Y = 646, isActive = true };
listPoints.Add(obj);
BindStore();
}
private void BindStore()
{
StrALEMaps.DataSource = this.listPoints;
this.StrALEMaps.DataBind();
}
public class MapPoints
{
public int MapType
{
get;
set;
}
public int MapID
{
get;
set;
}
public string Description
{
get;
set;
}
public int X
{
get;
set;
}
public int Y
{
get;
set;
}
public Boolean isActive
{
get;
set;
}
}
}
}
Please let us know your thoughts.....
Thanks & Regards
Mohan