Atlas: Using Dynamic Controls within a ModalPopUp (with selection from GridView )
In my opinion, the ModalPopUp is the most useful AJAX enabled control the toolkit provides. I prefer it because I like the ability to provide an input form on top of selection lists so that there is not the issue of writing controls that redirect to new pages and dealing with using query strings or server.transfer methods. However, like most new technologies - trying to find programming examples that deal with coding styles beyond Master Pages and code-behind is difficult. In this article, I'll discuss how to implement a gridview enabled control that when a record is selected for editing - will use only one ModalPopUp instance and displays dynamically loaded control.
(Additionally: I have code included that shows how to do 'highlighted rows' and multi-delete functionality in the gridview)
Before going further:
1. This is not a complete code project example so there is no complete working project / solution to download available. The files provided are merely the code snippets so that you can see the process.
2. There may be improvements that may be made now and down the road. I am neither a rocket scientist or coding genius - and the methods and public properties exposed / provided by the Atlas ToolKit may change as this article targets Sep 17, 2006 release of the Atlas ToolKit that was available on CodePlex. (Post July CTP).
3. This code is based on my own work converting the Community Starter Kit from Asp.Net 1.1 to 2.0. So, if you are looking to play around with any of the code or understand it in a larger context then that would be the sample that I am referencing in this article.
Scenario:
Gridview on a page that is populated with records that may be edited. This particular gridview is a base control that is inherited by other controls.
There is a single ModalPopupExtender on the page, that contains nothing but a placeholder.
The placeholder is used to dynamically load another web / user control.
This is a Asp.Net 2.0 C# example and code is at END of article.
ATLAS BUG NOTE: Not sure if it is a bug or not, however, I have noted that you can not have two same named controls if using the ModalPopUp. In other words, if your main control has a <asp:button id="btnAdd"...> then the control being loaded dynamically in the placeholder of the Modal can not have a <asp:button id="btnAdd"...>. Doing so will cause assertion failures. So, in the example code there is no duplicate naming of either parameters in the C# code or the .ascx .
The difficulty with using dynamic controls in a ModalPopUp arises from the fact that only partial postbacks are generated and that when dynamically loading anything - the parent control will actually have no idea what the dynamic control does. Dynamic controls are also unique in that the actual page will be unaware it was ever in the placeholder, and so - the control must always be recreated. When the dynamic control is recreated - it loses its parameters / variable values. Luckily there is a new feature in 2.0 and that is LoadControlState() and the corresponding SaveControlState().
Tip: If you want to populate the control with prior client side value - always make sure you assign the ID in the code. For example, ctlToAdd is our dynamic control to be placed in the placeholder. ALWAYS assign it the same ID (Do not rely on .Net to do it properly in a Ajax / At;las enviroment) ie: ctlToAdd.Id="ctlToAdd1" - then do the ctlToLoad.Controls.Add(ctlToAdd); This nifty trick is the method used to grab previous viewstate / control state without necessarily coding for it.
It is a common misconception that AJAX provides asynchronous behavior and therefore the server side objects are created only once. Unfortunately this is not true. The client side objects are always there and updated partially during the process - but the only true asynchrous event is the client side communication. When a postback is made to the server - the WHOLE page has to be regenerated each and every time. The only difference in the postback response from the server perspective is that is only for what was requested.
Another issue, is that all of the data loading for a dynamic control can not be done using the (!Page.Postback) because the control will always be loaded in the postback process. To work around this issue a boolean parameter is used to spoof the PostBack indication - or in other words to be used in replace of the (!Page.Postback) check. This way form desired by a edit selection in the gridview will be loaded fresh and viewstate / control states updated within the ModalPopup.
IPostBackHandler must be implemented in the Dynamic Control (as well as the Parent Control). Normal Asp.Net control actions have to be overridden for certain submit behaviors like checkBox, dropdownlists, etc..AutoPostBack features of controls must be set to false, and on buttons you have to set the UseSubmitBehavior="false". Then wire up javascript onsubmit behaviors. Otherwise, the ModalPopUp will always close unless you code against that behavior. The side effect of that behavior is that on the client side all of the viewstate for the dynamic control is disposed.
So how does one keep the modal window open? The method I use in this example is a IsInModalMode boolean in the Parent Control which tracks this value and will call the ShowModal() at the correct point in the Page cycle and reload the Dynamic Control so it can handle its targetted postback event..
Additional ATLAS info...
DEBUG Mode set to false. This is just an eroneous tip and doesn't solve your actual problem - it only disquises. The one bad thing about Atlas / Ajax is that it hides on the client side - server side problems. For instance I kept getting assertion failures on a form being popped up. It wasn't the same named control issue. Instead I had to nest a ton of try and catch exception statements and log them to my db. It resulted in being I was casting one boolean to string in viewstate parameter on the set value. The form still showed however. Even having a exception logger - it never logged the event until manually I traced and caught it.
EventValidation errors. Again this is a issue with how viewstate is managed. If a control is not properly setup (and with Atlas - it is possible to load controls and have a form that looks like it works but there is an underlying issue) and you are not properly handling viewstate and control state - there will be detected 'dirty viewstate' which basically throws the Page.IsValid to false. The problem here can be solved is always call Page.Validate() prior to any Page.IsValid(). It will clean up the viewstate and validation errors...So there is no need to turn off EventValidation - there is an issue with your code - and in some cases you may not want to use the built in validators - roll your own.
The following code - albiet a bit messy - does work. It has three controls. a base control which holds all of the actual data, gridview, and Modal handling code. Parent Control which inherits the base control. Its only purpose in life is to set the proper datasource for the base, and load the dynamic control. The dynamic control which is a form with tons of textboxes, checkboxes, and a dropdownlist.
It is easier to just show the code - there is a download available with the code listed below.
bllLogging is a logging routine I use. Replace with Context.Trace.Warn. I find it handy to track all the processes as it helps understand the Page Cycle process.
.base Control c#
using System;
using System.Data;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Configuration;
using System.Drawing;
using System.Web.UI.Design;
using System.Reflection;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;
//Atlas / AJAX
using Microsoft.Web.UI;
using Microsoft.Web.UI.Controls;
using AtlasControlToolkit;
using Cavalia.Enums;
namespace Cavalia.SkinHandler
{
public abstract class GridViewModal : SkinnedCommunityControl, IPostBackDataHandler, IPostBackEventHandler
{
//These delegates are used so that the derived controls do not need to
//implement the complex logic.
public delegate DataSet GetGridViewItemsDelegate(int sortBy, int orderBy, int showOnly, string SPtoUse);
public delegate ArrayList GetFilterByItemsDelegate();
public delegate DataSet GetShowOnlyItemsDelegate();
public GetGridViewItemsDelegate GetGridViewItems;
public GetFilterByItemsDelegate GetFilterByItems;
public GetShowOnlyItemsDelegate GetShowOnlyItems;
protected Button btnAdd; //Displays a blank modal
protected Button btnEdit;
protected Button btnContinue;
protected Panel pnlPopUp; //Used for Modal
protected Panel pnlForm;
/// <summary>
/// Here we place in the common controls and event handlers that we inherit from
/// </summary>
protected GridView grdData;
protected DropDownList dropShowOnly;
protected DropDownList dropSortBy;
protected DropDownList dropOrderBy;
protected DropDownList dropFilterBy;
protected Button btnCheckAll;
protected Button btnUnCheckAll;
protected Button btnCancel;
protected Button btnDelChecked;
//Modal Requirements
protected PlaceHolder ctlLoad;
protected ModalPopupExtender MyModalExtender;
protected ScriptManager SM;
protected UpdatePanel UpdatePanelModal;
protected Panel PanelModal;
protected Button Target;
public event SkinLoadEventHandler SkinLoad;
public event SubmitEventHandler Submit;
public event PreviewEventHandler Preview;
public event ContinueEventHandler Continue;
protected Sorter objSorter = null;
//used to determine if we need to reload the dynamic control...
protected string PBArgument = String.Empty;
#region ViewState Requirements
//This sets whether or not the Modal Form is being displayed.
//Important becuase the Modal Form is actually a child control and both
//the parent and child need to be aware if it is in Modal Mode. Remember
//there is no such thing as a 'non postback' when dynamically invoking
//a modal window because it is seen as part of the parent page. IsInModalMode
//basically spoofs a intial page load for the control being loaded in the
//modal window.
//
//The child control will bubble certain events and the parent will raise
//events on the child control to indicate when and if the Modal should be closed.
public bool IsInModalMode
{
get
{
return (string)ViewState["IsInModalMode"] != null ?
Convert.ToBoolean((string)ViewState["IsInModalMode"]) : false;
}
set { ViewState["IsInModalMode"] = value.ToString(); }
}
//Set in one of three places:
//1. Retrieved from the database based on Page Type or Named Page setting
//2. Analyzed from browser detection (overrides everything)
//3. Control that inherits this may override this setting allowing MOD
// developers to force page redirections.
//
// Important to note that if false, then we will remove all of the
// Atlas enabled controls.
public bool UsesModalForm
{
get
{
return (string)ViewState["UsesModalForm"] != null ?
Convert.ToBoolean((string)ViewState["UsesModalForm"]) : false;
}
set { ViewState["UsesModalForm"] = value.ToString(); }
}
public int editID
{
get
{
return (string)ViewState["editID"] != null ?
Convert.ToInt32((string)ViewState["editID"]) : -1;
}
set { ViewState["editID"] = value.ToString(); }
}
public string modeName
{
get
{
return (string)ViewState["modeName"] != null ?
(string)ViewState["modeName"] : "Unknown";
}
set { ViewState["modeName"] = value; }
}
public int TotalRecords
{
get
{
if (ViewState["TotalRecords"] == null)
return -1;
else
return (int)ViewState["TotalRecords"];
}
set { ViewState["TotalRecords"] = value; }
}
public string SortOrder
{
get
{
EnsureChildControls();
if (objSorter != null)
return objSorter.SelectedSortOrder;
else
return "Default";
}
}
public string SpToUseForGridViewCollection
{
get
{
return (string)ViewState["SpToUseForGridViewCollection"] != null ?
(string)ViewState["SpToUseForGridViewCollection"] : "Unknown";
}
set { ViewState["SpToUseForGridViewCollection"] = value; }
}
//These are for the modal to inherit. This way we centralize all of the viewstate requirements
//and any modal popup style page can just reference the parent.
#endregion
//*********************************************************************
//
// ContentAddPage Constructor
//
// Calls the base SkinnedCommunityControl constructor
// and assigns the default page skin. Also checks whether
// current user has permissions to add a book.
//
//*********************************************************************
public GridViewModal()
: base()
{
if (!objUserInfo.MayEdit)
CommunityGlobals.ForceLogin();
}
//*********************************************************************
//
// OnInit Method
//
// Make sure that the content of the section matches the content of
// the page. Otherwise, the user is trying something sneaky.
//
//*********************************************************************
protected override void OnInit(EventArgs e)
{
bllLogging.RecordMessage("GridViewDefault: OnInit", "This is a tracking message", Severity.Severe, "GridViewModal", "");
}
//*********************************************************************
//
// SkinType Property
//
// Specifies the skins directory where this page's skin file is located.
//
//*********************************************************************
override protected string SkinType
{
get { return "ControlSkins"; }
}
//*********************************************************************
//
// InitializeSkin Method
//
// Retrieves all the controls from the page skin.
//
//*********************************************************************
override protected void InitializeSkin(Control skin)
{
bllLogging.RecordMessage("GridViewDefault: InitializeSkin", "This is a tracking message", Severity.Severe, "GridViewModal", "");
//AJAX Requirements
SM = (ScriptManager)GetControl(skin, "SM");
ctlLoad = (PlaceHolder)GetOptionalControl(skin, "ctlLoad");
UpdatePanelModal = (UpdatePanel)GetOptionalControl(skin, "UpdatePanelModal");
Target = (Button)GetOptionalControl(skin, "Target");
PanelModal = (Panel)GetOptionalControl(skin, "PanelModal");
MyModalExtender = (ModalPopupExtender)GetOptionalControl(skin, "MyModalExtender");
//GridView Related
grdData = (GridView)GetOptionalControl(skin, "grdData");
dropShowOnly = (DropDownList)GetOptionalControl(skin, "dropShowOnly");
dropSortBy = (DropDownList)GetOptionalControl(skin, "dropSortBy");
dropOrderBy = (DropDownList)GetOptionalControl(skin, "dropOrderBy");
dropFilterBy = (DropDownList)GetControl(skin, "dropFilterBy");
btnCheckAll = (Button)GetOptionalControl(skin, "btnCheckAll");
btnUnCheckAll = (Button)GetOptionalControl(skin, "btnUnCheckAll");
btnDelChecked = (Button)GetOptionalControl(skin, "btnDelChecked");
this.btnDelChecked.Click += new EventHandler(this.btnDelChecked_Click);
this.btnCheckAll.Click += new System.EventHandler(this.btnCheckAll_Click);
this.btnUnCheckAll.Click += new System.EventHandler(this.btnUnCheckAll_Click);
this.dropOrderBy.SelectedIndexChanged += new EventHandler(this.OrderChanged);
this.dropShowOnly.SelectedIndexChanged += new EventHandler(this.OrderChanged);
this.dropSortBy.SelectedIndexChanged += new EventHandler(this.OrderChanged);
this.dropFilterBy.SelectedIndexChanged += new EventHandler(this.OrderChanged);
this.grdData.RowCommand += new GridViewCommandEventHandler(this.Row_Click);
this.grdData.PageIndexChanging += new GridViewPageEventHandler(this.grdData_PageIndexChanged);
this.grdData.RowDataBound += new System.Web.UI.WebControls.GridViewRowEventHandler(this.GridView_RowDataBound);
// Find and hide Add Button
btnAdd = (Button)GetOptionalControl(skin, "btnAddNew");
if (btnAdd != null)
btnAdd.Visible = false;
else this.btnAdd.Click += new EventHandler(this.OnSubmit);
PBArgument = HttpContext.Current.Request.Params["__EVENTARGUMENT"];
bllLogging.RecordMessage("GridViewDefault: InitializeSkin: EventArgument:"+PBArgument, "This is a tracking message", Severity.Severe, "GridViewModal", "");
/*
btnCancel = (Button)GetOptionalControl(skin, "btnCancel");
if (btnCancel != null)
btnCancel.Visible = false;
*/
// Find Edit Button
//btnEdit = (Button)GetOptionalControl(skin, "btnEdit");
//btnEdit.Click += new EventHandler(OnSubmit);
// Find Preview Panel
pnlPopUp = (Panel)GetOptionalControl(skin, "pnlPopUp");
if (pnlPopUp != null)
{
// Find Form Panel
pnlForm = (Panel)GetControl(skin, "pnlForm");
// Hide the Preview Panel on first load
if (!Page.IsPostBack)
pnlPopUp.Visible = false;
}
// Call Skin Load event
OnSkinLoad(this, new SkinLoadEventArgs(skin));
}
protected virtual void OnSkinLoad(Object s, SkinLoadEventArgs e)
{
bllLogging.RecordMessage("GridViewDefault: OnSkinLoad", "This is a tracking message", Severity.Severe, "", "");
if (SkinLoad != null)
SkinLoad(s, e);
}
protected virtual void OnSubmit(Object s, EventArgs e)
{
if (Submit != null)
Submit(s, EventArgs.Empty);
}
protected virtual void OnPreview(Object s, EventArgs e)
{
if (Page.IsValid)
{
pnlForm.Visible = false;
pnlPopUp.Visible = true;
if (Preview != null)
Preview(s, e);
}
}
protected virtual void OrderChanged(Object s, EventArgs e)
{
modeName = dropFilterBy.SelectedValue.ToString();
//BindContent();
BindGridView();
}
protected override void OnPreRender(EventArgs e)
{
bllLogging.RecordMessage("GridViewDefault: PreRender and IsInModal =" + IsInModalMode, "This is a tracking message", Severity.Severe, "GridViewModal", "");
if (!Page.IsPostBack)
{
// BindContent();
BindGridView();
}
}
protected virtual void BindContent()
{
bllLogging.RecordMessage("GridViewDefault: BindContent", "This is a tracking message", Severity.Severe, "GridViewModal", "");
// if (!Page.IsPostBack)
// {
if (dropShowOnly != null)
{
dropShowOnly.DataSource = GetShowOnlyItems();
dropShowOnly.DataTextField = "Name";
dropShowOnly.DataValueField = "ID";
dropShowOnly.DataBind();
// Assign default value
dropShowOnly.Items[0].Selected = true;
}
if (dropFilterBy != null)
{
dropFilterBy.DataSource = GetFilterByItems();
dropFilterBy.DataTextField = "MenuType";
dropFilterBy.DataValueField = "MenuType";
dropFilterBy.DataBind();
//dropFilterBy.Items.Add(new ListItem("Sections", "Sections"));
dropFilterBy.Items[0].Selected = true;
modeName = dropFilterBy.SelectedValue.ToString();
}
// }
}
protected virtual void BindGridView()
{
//Seperated method because we may need to override the
//SpToUseForGridView prior to the binding...
try
{
grdData.DataSource = GetGridViewItems(Int32.Parse(dropSortBy.SelectedItem.Value), Int32.Parse(dropOrderBy.SelectedItem.Value), Int32.Parse(dropShowOnly.SelectedItem.Value), SpToUseForGridViewCollection);
grdData.DataBind();
}
catch (Exception ex)
{
bllLogging.RecordError("Could Not Bind ContentList", ex, Severity.Severe, "ContentListPage", "Check Exception log for more information. Typically this will be a missing control in your skin.");
}
}
protected virtual void BindModal()
{
//EnsureChildControls();
IsInModalMode = true;
bllLogging.RecordMessage("GridViewDefault: BindModal", "This is a tracking message", Severity.Severe, "GridViewModal", "");
}
protected virtual void btnDelChecked_Click(object sender, EventArgs e)
{
//Do Delete Checked Items here....
}
protected virtual void OnContinue(Object s, EventArgs e)
{
pnlForm.Visible = true;
pnlPopUp.Visible = false;
if (Continue != null)
Continue(s, e);
}
protected virtual void btnCheckAll_Click(object sender, EventArgs e)
{
foreach (GridViewRow i in grdData.Rows)
{
CheckBox chkSelect = (CheckBox)i.FindControl("chkSelect");
chkSelect.Checked = true;
}
}
protected virtual void btnUnCheckAll_Click(object sender, EventArgs e)
{
foreach (GridViewRow i in grdData.Rows)
{
CheckBox chkSelect = (CheckBox)i.FindControl("chkSelect");
chkSelect.Checked = false;
}
}
//Manage Conytrol State
//Required for MOdal operations
protected override void LoadControlState(object savedState)
{
object[] controlState = (object[])savedState;
base.LoadControlState(controlState[0]);
this.editID = (int)controlState[1];
this.modeName = (string)controlState[2];
this.IsInModalMode = (bool)controlState[3];
//this.submitMode = (string)controlState[4];
bllLogging.RecordMessage("GridViewDefault: LoadControlState In Modal:"+IsInModalMode, "This is a tracking message", Severity.Severe, "GridViewModal", "");
}
protected override object SaveControlState()
{
bllLogging.RecordMessage("GridViewDefault: SaveControlState", "This is a tracking message", Severity.Severe, "GridViewModal", "");
object baseControlState = base.SaveControlState();
object[] controlState = new object[4] {
baseControlState, this.editID, this.modeName,
this.IsInModalMode// ,this.submitMode
};
return controlState;
}
//Gridview Selection Changes
protected virtual void grdData_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
}
protected virtual void grdData_PageIndexChanged(object sender, EventArgs e)
{
}
protected virtual void grdData_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
}
protected virtual void grdData_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected virtual void Row_Click(Object s, GridViewCommandEventArgs e)
{
}
//Gridview RowDataBound Event -
//We add all of the common features here using findoptional
//so if skin doesn't have it we do not use it...
protected virtual void GridView_RowDataBound(Object s, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Note: Here is where we change the button submit so that
//our IPostBackHandler can properly handle AJAX requests.
int editID = (int)DataBinder.Eval(e.Row.DataItem, "id");
e.Row.Attributes.Add("onMouseOver", "SetNewColor(this);");
e.Row.Attributes.Add("onMouseOut", "SetOldColor(this);");
e.Row.Attributes.Add("onDblClick", Page.ClientScript.GetPostBackEventReference(this, e.Row.RowIndex.ToString()));
string sectionName = (string)DataBinder.Eval(e.Row.DataItem, "name");
ImageButton btnDelete = (ImageButton)e.Row.FindControl("btnDelete");
btnDelete.ImageUrl = ResolveUrl("~/Communities/" + objSectionInfo.Skin + "/Images/Admin/delete.gif");
btnDelete.Attributes.Add("onclick", String.Format("return confirm('Are you sure you want to delete the \"{0}\" section?')", sectionName));
ImageButton btnEdit = (ImageButton)e.Row.FindControl("btnEdit");
btnEdit.ImageUrl = ResolveUrl("~/Communities/" + objSectionInfo.Skin + "/Images/Admin/edit.gif");
string js = Page.ClientScript.GetPostBackEventReference(this, "Edit${0}");
js = String.Format(js, editID.ToString());
btnEdit.Attributes["onclick"] = js;
}
}
//Provides the check to see if ModalPopUp is visible or not.
protected virtual void ShowModalPopup()
{
ModalPopupProperties MyPopup = MyModalExtender.GetTargetProperties(Target);
if (MyPopup == null)
{
bllLogging.RecordMessage("popup is null sigh", "This is a tracking message", Severity.Severe, "GridViewModal", "");
}
else
{
if (IsInModalMode)
{
bllLogging.RecordMessage("GridViewDefault: ShowModalPopup Show()", "This is a tracking message", Severity.Severe, "GridViewModal", "");
MyPopup.Show();
}
else
{
bllLogging.RecordMessage("GridViewDefault: ShowModalPopup Hide()", "This is a tracking message", Severity.Severe, "GridViewModal", "");
MyPopup.Hide();
}
}
}
//This is for handling Postbacks
public void RaisePostBackEvent(String eventArgument)
{
//Page.ClientScript.GetPostBackEventReference(this, String.Empty);
GridViewSelectEventArgs e = null;
GridViewRowEventHandler f = null;
int selectedRowIndex = -1;
bllLogging.RecordMessage("GridView: Made it RaisePostBackEvent with=" + eventArgument.ToString(), "grdDataing", Severity.Severe, "GridViewModal", "Bummer");
if (eventArgument == "cancel")
{
IsInModalMode = false;
ShowModalPopup();
}
if (!string.IsNullOrEmpty(eventArgument))
{
string[] args = eventArgument.Split('$');
if (string.Compare(args[0], "Select", false, System.Globalization.CultureInfo.InvariantCulture) == 0 && args.Length > 1)
{
Int32.TryParse(args[1], out selectedRowIndex);
//SelectedIndex = ((GridViewSelectEventArgs)e).NewSelectedIndex;
e = new GridViewSelectEventArgs(selectedRowIndex);
grdData_SelectedIndexChanging(this, e);
}
else if (string.Compare(args[0], "Edit", false, System.Globalization.CultureInfo.InvariantCulture) == 0 && args.Length > 1)
{
Int32.TryParse(args[1], out selectedRowIndex);
bllLogging.RecordMessage("GRIDVIEWMODAL: RaisePostBackEvent w " + args[0].ToString() + "Selected Row Index = " + selectedRowIndex, "grdDataing", Severity.Severe, "GridViewModal", "Bummer");
editID = selectedRowIndex;
//Assign the Dynamic Control - init it
BindModal();
//Show the Modal
ShowModalPopup();
}
else
{
Int32.TryParse(args[0], out selectedRowIndex);
e = new GridViewSelectEventArgs(selectedRowIndex);
// myframe.Attributes["src"] = "~/EditSectionsBasic.aspx?id=" + selectedRowIndex.ToString();
grdData_SelectedIndexChanging(this, e);
}
}
}
void IPostBackDataHandler.RaisePostDataChangedEvent()
{
bllLogging.RecordMessage("(RaisePostDataChangedEvent)", "start RaisePostDataChangedEvent", Severity.Severe, "EditNamedPage", "Trackng");
// Call the event method. This is optional.
OnChange(EventArgs.Empty);
}
protected virtual void OnChange(EventArgs e)
{
bllLogging.RecordMessage("(OnChange)", "Raiseing change event", Severity.Severe, "EditNamedPage", "Trackng");
if (Change != null)
// Raise event.
Change(this, e);
}
// Get data from the user.
//This is not being used I do not think....future enhancement
//
bool IPostBackDataHandler.LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection)
{
bllLogging.RecordMessage("(LoadPostData)", "start LoadPostData event", Severity.Severe, "EditNamedPage", "Trackng");
if (postDataKey != null)
{
bllLogging.RecordMessage("(LoadPostData) PDK=" + postDataKey, postCollection.ToString(), Severity.Severe, "NamedPagesDefault", "Trackng");
return true;
}
return false;
}
public event EventHandler Change;
public event EventHandler Changed
{
add
{
bllLogging.RecordMessage("(EventHandler Changed ADD)", "start EventHandler Changed event", Severity.Severe, "EditNamedPage", "Trackng");
Events.AddHandler(EventControlChanged, value);
}
remove
{
bllLogging.RecordMessage("(EventHandler Changed Remove)", "start EventHandler Changed event", Severity.Severe, "EditNamedPage", "Trackng");
Events.RemoveHandler(EventControlChanged, value);
}
}
private static readonly object EventControlChanged = new object();
}
}
Colorized by: CarlosAg.CodeColorizer
.Parent Control C#
using System;
using System.Data;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Configuration;
using System.Drawing;
using System.Web.UI.Design;
using System.Reflection;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;
using AtlasControlToolkit;
using Microsoft.Web.UI;
using Microsoft.Web.UI.Controls;
using Cavalia.SkinHandler;
using Cavalia.ContentPages;
using Cavalia.Enums;
using Cavalia;
namespace Cavalia.Admin
{
/// <summary>
///***********************************************************
/// Named Pages MOD
/// Jody Winningham
/// July 2006 - WBCB.com
///
/// MOD allows for admistration of Nmed Pages via Webform
///***********************************************************
/// </summary>
///
public class NamedPagesDefault : GridViewModal
{
#region Common Variables
//Common For Using GridViews
string _skinFileName = "/admin/NamedPages_Default.ascx";
GetShowOnlyItemsDelegate _GetShowOnlyItems = new GetShowOnlyItemsDelegate(dalSection.PageTypesGetGroups);
GetFilterByItemsDelegate _GetFilterByItems = new GetFilterByItemsDelegate(ModeTypeUtility.GetModeTypes);
GetGridViewItemsDelegate _GetGridViewItems = new GetGridViewItemsDelegate(dalSection.GetAllWithSortOptions);
//End of Common Add Specific UI stuff here...
#endregion
override protected string SkinType
{
get { return "ControlSkins"; }
}
void _SkinLoad(Object s, SkinLoadEventArgs e)
{
// bllLogging.RecordMessage("NamedPagesDefault: SkinLoad", "This is a tracking message", Severity.Severe, "NamedPagesDefault", "");
EnsureChildControls();
if (PBArgument == "submit")
{
EditNamedPage ctlToAdd = new EditNamedPage();
ctlToAdd.ID = "ctlToAdd1";
// ctlToAdd.s
ctlToAdd.Visible = true;
ctlLoad.Visible = true;
ctlLoad.Controls.Add(ctlToAdd);