protected void lnkDownload_onclick(Object sender, EventArgs e) { clearMessages(); try { LinkButton btn = (LinkButton)sender; GridViewRow row = (GridViewRow)btn.NamingContainer; int _lgid = Convert.ToInt32(grdvltrTemplates.DataKeys[row.RowIndex].Value); string _letterCode = LettersGenDAL.getLetterTypeCode(_lgid); string _template = LettersGenDAL.getTemplate(_lgid); string _schemaUri = "EBAnamespace"; string _schemaAlias = "EBAHRA"; string _schemaPath = ""; if (_letterCode.Equals("HRB1") || _letterCode.Equals("HRB2")) { _schemaPath = FilePaths.getFilePath("SchemaValid"); } else { _schemaPath = FilePaths.getFilePath("Schema"); } string _filepath = "C:\\EBATemp\\"; string _file = _filepath + "Template.xml"; int _seq = 0; ClientScriptManager cs = Page.ClientScript; if (!cs.IsClientScriptBlockRegistered(_seq + "DeleteFile")) { cs.RegisterClientScriptBlock(typeof(Page), _seq + "DeleteFile", "DeleteFile('" + _file.Replace("\\", "\\\\") + "');", true); } if (!cs.IsClientScriptBlockRegistered(_seq + "SaveFile")) { cs.RegisterClientScriptBlock(typeof(Page), _seq + "SaveFile", "SaveFile('" + _template.Replace(Environment.NewLine, "") + "', '" + _file.Replace("\\", "\\\\") + "');", true); } if (!cs.IsClientScriptBlockRegistered(_seq + "DownloadWord")) { cs.RegisterClientScriptBlock(typeof(Page), _seq + "DownloadWord", "DownloadTemplate('" + _file.Replace("\\", "\\\\") + "', '" + _schemaPath + "','" + _schemaAlias + "','" + _schemaUri + "');", true); } } catch (Exception ex) { errorDiv1.Visible = true; lblErrorTemplates.Text = "Error downloading File - " + ex.Message; } }
protected void lnkView_onclick(Object sender, EventArgs e) { clearMessages(); try { LinkButton btn = (LinkButton)sender; GridViewRow row = (GridViewRow)btn.NamingContainer; int _lgid = Convert.ToInt32(grdvltrTemplates.DataKeys[row.RowIndex].Value); string _template = LettersGenDAL.getTemplate(_lgid); //string _filepath = FilePaths.getFilePath("Uploads"); //string _file = _filepath + "Template.xml"; string _filepath = "C:\\EBATemp\\"; string _file = _filepath + "Template.xml"; int _seq = 0; ClientScriptManager cs = Page.ClientScript; if (!cs.IsClientScriptBlockRegistered(_seq + "SaveFile")) { cs.RegisterClientScriptBlock(typeof(Page), _seq + "SaveFile", "SaveTextFile('" + _template.Replace(Environment.NewLine, "") + "', '" + _file.Replace("\\", "\\\\") + "');", true); } if (!cs.IsClientScriptBlockRegistered(_seq + "ViewWord")) { cs.RegisterClientScriptBlock(typeof(Page), _seq + "ViewWord", "OpenWord('" + _file.Replace("\\", "\\\\") + "');", true); } } catch (Exception ex) { errorDiv1.Visible = true; lblErrorTemplates.Text = "Error viewing File - " + ex.Message; } }