//**************************************************************** // // The Page_Load event on this Page is used to obtain the ModuleId // and ItemId of the event to edit. // // It then uses the ASPNET.StarterKit.Portal.EventsDB() data component // to populate the page's edit controls with the event details. // //**************************************************************** private void Page_Load(object sender, System.EventArgs e) { // Determine ModuleId of Events Portal Module moduleId = Int32.Parse(Request.Params["Mid"]); // Verify that the current user has access to edit this module if (PortalSecurity.HasEditPermissions(moduleId) == false) { Response.Redirect("~/Admin/EditAccessDenied.aspx"); } // Determine ItemId of Events to Update if (Request.Params["ItemId"] != null) { itemId = Int32.Parse(Request.Params["ItemId"]); } // If the page is being requested the first time, determine if an // event itemId value is specified, and if so populate page // contents with the event details if (Page.IsPostBack == false) { if (itemId != 0) { // Obtain a single row of event information ASPNET.StarterKit.Portal.EventsDB events = new ASPNET.StarterKit.Portal.EventsDB(); SqlDataReader dr = events.GetSingleEvent(itemId); // Read first row from database dr.Read(); // Security check. verify that itemid is within the module. int dbModuleID = Convert.ToInt32(dr["ModuleID"]); if (dbModuleID != moduleId) { dr.Close(); Response.Redirect("~/Admin/EditAccessDenied.aspx"); } TitleField.Text = (String)dr["Title"]; DescriptionField.Text = (String)dr["Description"]; ExpireField.Text = ((DateTime)dr["ExpireDate"]).ToShortDateString(); CreatedBy.Text = (String)dr["CreatedByUser"]; WhereWhenField.Text = (String)dr["WhereWhen"]; CreatedDate.Text = ((DateTime)dr["CreatedDate"]).ToShortDateString(); dr.Close(); } // Store URL Referrer to return to portal ViewState["UrlReferrer"] = Request.UrlReferrer.ToString(); } }