public class ClientSidePage : System.Web.UI.Page
{
#region Methods for Prompting the User to Save Before Leaving the Page
protected void MonitorChanges(WebControl wc)
{
if (wc == null) return;
if (wc is CheckBoxList || wc is RadioButtonList)
for (int i = 0; i < ((ListControl) wc).Items.Count; i++)
{
Page.RegisterArrayDeclaration("monitorChangesIDs", "\"" + string.Concat(wc.ClientID, "_", i.ToString()) + "\"");
Page.RegisterArrayDeclaration("monitorChangesValues", "null");
}
else
{
Page.RegisterArrayDeclaration("monitorChangesIDs", string.Concat("\"", wc.ClientID, "\""));
Page.RegisterArrayDeclaration("monitorChangesValues", "null");
}
AssignMonitorChangeValuesOnPageLoad();
}
protected void AssignMonitorChangeValuesOnPageLoad()
{
if (!Page.IsStartupScriptRegistered("monitorChangesAssignment"))
{
Page.RegisterStartupScript("monitorChangesAssignment",
@"");
Page.RegisterClientScriptBlock("monitorChangesAssignmentFunction",
@"");
}
}
protected void BypassModifiedMethod(WebControl wc)
{
wc.Attributes["onclick"] = string.Concat("javascript:", GetBypassModifiedMethodScript());
}
protected string GetBypassModifiedMethodScript()
{
return "needToConfirm = false;";
}
#endregion
}