/// <summary>
/// After the Update button is clicked, updates the template or creates a new one,
/// depending if in edit mode or not.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnUpdate_Click(object sender, EventArgs e)
{
var tm = new Internal.TemplateManager(App);
var templatePath = ddlTemplateFiles.SelectedValue;
if (!pnlSelectTemplateFile.Visible)
{
templatePath = tm.CreateTemplateFileIfNotExists(txtTemplateFileName.Text, ddlTemplateTypes.SelectedValue, ddlTemplateLocations.SelectedValue, Server, LocalizeString("NewTemplateFile.DefaultText"));
}
var templateId = ModeIsEdit ? Template.TemplateId : new int?();
var pipelineEntityId = ddlDataPipeline.SelectedValue == "0" ? (int?)null : Int32.Parse(ddlDataPipeline.SelectedValue);
if (!chkSeparateContentPresentation.Checked)
{
ctrPresentationType.ContentTypeStaticName = "";
}
App.TemplateManager.UpdateTemplate(templateId, txtTemplateName.Text, templatePath, ctrContentType.ContentTypeStaticName, ctrContentType.DemoEntityID, ctrPresentationType.ContentTypeStaticName, ctrPresentationType.DemoEntityID, ctrListContentType.ContentTypeStaticName, ctrListContentType.DemoEntityID, ctrListPresentationType.ContentTypeStaticName, ctrListPresentationType.DemoEntityID, ddlTemplateTypes.SelectedValue, chkHidden.Checked, ddlTemplateLocations.SelectedValue, chkEnableList.Checked, chkPublishSource.Checked, txtPublishStreams.Text, pipelineEntityId, txtViewNameInUrl.Text);
// old Redirect to the manage templates control
//var RedirectUrl = UrlUtils.PopUpUrl(Globals.NavigateURL(SexyContent.ControlKeys.ManageTemplates, "mid", ModuleId.ToString(), SexyContent.AppIDString, AppId.ToString()), this, PortalSettings, false, true);
//Response.Redirect(RedirectUrl);
// New 2015-09-19 close this window - temporary solution till this dialog is obsolete
Response.Write("<script>window.close();</script>");
}