Skip to main content

Dynamic Image Url Code Behind Code To Export Multiple Images to Word File

[vb.code]
* Write This Code in Button Click Event.
*  img1,2,3,4 variable is used to get and store the image name which is stored in the session.
* My Scenario was export all four chart control images into one ms-word file.
* Here all image name are unique and stored into the session variable.


Protected Sub btnExportAllChart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExportAllChart.Click
   
        Dim serverurl As String =   Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/TempImageFiles/"
        Dim img1 As String = serverurl + Session("ImageName1")
        Dim img2 As String = serverurl + Session("ImageName2")
        Dim img3 As String = serverurl + Session("ImageName3")
        Dim img4 As String = serverurl + Session("ImageName4")
        HttpContext.Current.Response.Clear()
        HttpContext.Current.Response.Charset = ""
        HttpContext.Current.Response.ContentType = "application/msword"
        Dim strFileName As String = FileName+ ".doc"
        HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName)
        Dim strHTMLContent As New StringBuilder
       
       
strHTMLContent.Append("<table align='Center'>".ToString())

        strHTMLContent.Append("<tr>".ToString())
        strHTMLContent.Append("<td>".ToString())
        strHTMLContent.Append("<img src='" + img1 + "' width='500' height='400'/>".ToString())
        strHTMLContent.Append("</td>".ToString())
        strHTMLContent.Append("<td>".ToString())
        strHTMLContent.Append("<img src='" + img2 + "' width='500' height='400'/>".ToString())
        strHTMLContent.Append("</td>".ToString())
        strHTMLContent.Append("</tr>".ToString())
       
strHTMLContent.Append("<tr>".ToString())
        strHTMLContent.Append("<td>".ToString())
        strHTMLContent.Append("<img src='" + img3 + "' width='500' height='400'/>".ToString())
        strHTMLContent.Append("</td>".ToString())
        strHTMLContent.Append("<td>".ToString())
        strHTMLContent.Append("<img src='" + img4 + "' width='500' height='400'/>".ToString())
        strHTMLContent.Append("</td>".ToString())
        strHTMLContent.Append("</tr>".ToString())
     
        strHTMLContent.Append("</table>".ToString())
        HttpContext.Current.Response.Write(strHTMLContent)
        HttpContext.Current.Response.End()
        HttpContext.Current.Response.Flush()
    End Sub

OutPut:

Comments

Popular posts from this blog

Password Protected File Validation for(.doc/.docx/.xls/.xlsx/.pdf) file types

Password Protected File Validation for(.doc/.docx/.xls/.xlsx/.pdf) file types protected void btnUpload_Click( object sender, EventArgs e)         {             //Check if File Upload control has file or not             if (FileUpload1.HasFile)             {                 //Get Uploaded file bytes                 var bytes = FileUpload1.FileBytes;                 //Get Uploaded File Extension                 FileInfo objFileInfo = new FileInfo (FileUpload1.FileName);                 string StrFileExt = objFileInfo.Extension.ToUpper();                                 //Based on the File extension call appropriate user defined method.                 //For PDF file type                 if (StrFileExt == ".PDF" )                 {                     //Upload and save file in server temp folder                     var newfilename = DateTime .Now.GetHashCode() + FileUpload1.FileName;                     FileUpload1.SaveAs(Syst

Product/Application/ Software Security Testing

Product/Application/ Software Security Testing Application Security testing is the process to find security issues or security vulnerability in the application using automated and manual security scanner tools and share the identified issues or risk with development or application team. Process will remain mostly same in all the different types of application security scan. Before initiating security scan, its always good to identify the boundary and scope of your security testing.  Below are the few example of which we can consider as Application or software. ( Scope for Application Security Testing) Web Application, Portal. Web API. Desktop Software / Thick Client. Mobile Application. Web Services.  Plug in, Add-On The goal of application security is to secure the application and prevent the unwanted damaged. The process of performing security scan or audit is know as ASA (Application Security Assessment). Generally there are three types of ASA, SAST, DAST and PT. 

Improve SQL Server database design and performance

Improve SQL Server database design and performance http://www.dotnet-tricks.com/Tutorial/sqlserver/bM6H260812-Tips-to-improve-SQL-Server-performance.html