protected void cmdSave_Click(object sender, EventArgs e) { try { var Model = Components.Data.Model.Model.Instance(); //Find the old item and delete it. var OldData = (from x in Model.HTMLs where x.ModuleID == ModuleId select x).FirstOrDefault(); if (OldData != null) { Model.DeleteObject(OldData); } //Create the new data object. var NewData = new Components.Data.Model.HTML(); NewData.ID = Guid.NewGuid(); NewData.ModuleID = ModuleId; //The HTML from txtContent is encoded. Let's decode it. NewData.RawHTML = HttpUtility.HtmlDecode((txtContent as DotNetNuke.UI.UserControls.TextEditor).Text); NewData.CreatedDate = DateTime.Now.ToUniversalTime(); NewData.CreatedUserID = UserId; Model.HTMLs.AddToHTMLs(NewData); //Save the changes Model.SaveChanges(); //Redirect back to our main page. Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId)); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }