protected void btnSaveTemplate_Click(object sender, EventArgs e) { try { if (txtTemplateName.Text.Trim() == "") { string js = "alert('Enter template name');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "errorMail", js, true); return; } else if (txtTemplateBody.Text == "") { string js = "alert('Enter template body');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "errorMail", js, true); return; } else { if (MainView.ActiveViewIndex == 0) { BLL_Infra_Lib_ModuleTemp.Save_Module_Template(UDFLib.ConvertToInteger(hdnModuleTypeID.Value), txtTemplateName.Text.Trim(), txtTemplateBody.Text, GetSessionUserID(), 0); string js = "alert('Module Template Saved.');"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "SUCCESS", js, true); } if (MainView.ActiveViewIndex == 1) { BLL_Infra_Lib_ModuleTemp.Save_Module_Template(UDFLib.ConvertToInteger(hdnModuleTypeID.Value), txtTemplateName.Text.Trim(), txtTemplateBody.Text, GetSessionUserID(), 1); string js = "alert('Module Template Saved.');"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "SUCCESS", js, true); } if (MainView.ActiveViewIndex == 2) { BLL_Infra_Lib_ModuleTemp.Save_Module_Template(UDFLib.ConvertToInteger(hdnModuleTypeID.Value), txtTemplateName.Text.Trim(), txtTemplateBody.Text, GetSessionUserID(), 2); string js = "alert('Module Template Saved.');"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "SUCCESS", js, true); } } } catch (Exception ex) { string js = "alert('Error saving module template" + ex.Message.Replace("'", "") + "');window.close();"; ScriptManager.RegisterStartupScript(this, this.GetType(), "mailerror", js, true); } }