| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Image keeps getting ASPX extension
Hello All,
Could someone please tell me why my customized flyer will not let me right click the page and save it as a .jpg file? The form works fine and the flyer is displayed in the browser with the added text from the form, but when I try to save the image it saves it as an ASPX file only and even if you change the extension to jpeg it still does not open. Is there a way to fix this, or perhaps incorporate a save button that will let users save the customized flyer as a jpg? Thanks! Here's the code:<%@ Page Debug="True" %> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Drawing.Text" %> <%@ Import Namespace="System.Drawing.Imaging" %> <%@ Import Namespace="System.Drawing.Drawing2D" %> <script language="VB" runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) If Page.IsPostBack Then ' load an existing bitmap Dim oCanvas As Bitmap = CType(Bitmap.FromFile(Server.MapPath("images\closeoutclocks.png")), Bitmap) Dim encoderParams as System.Drawing.Imaging.EncoderParameters = new System.Drawing.Imaging.EncoderParameters() Dim g As Graphics = Graphics.FromImage(oCanvas) g.SmoothingMode = SmoothingMode.HighQuality g.TextRenderingHint = TextRenderingHint.AntiAlias Dim oColor As System.Drawing.Color Dim tColor As String = Request("tColor") Select Case tColor Case "black" oColor = Color.Black Case "white" oColor = Color.White Case "navy" oColor = Color.Navy Case "orange" oColor = Color.Orange Case Else oColor = Color.Black End Select Dim oBrush As New SolidBrush(oColor) ' render some text Dim f1 As Font = New Font("Arial",22) Dim Company As String = Request("TextBox1") g.DrawString(Company, f1,oBrush ,5,5) Dim FullName As String = Request("TextBox2") g.DrawString(FullName,f1,oBrush ,5,35) Dim Telephone As String = Request("TextBox3") g.DrawString(Telephone,f1,oBrush ,300,5) Dim Email As String = Request("TextBox4") g.DrawString(Email,f1,oBrush ,300,35) g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic g.SmoothingMode = SmoothingMode.HighQuality Dim quality as long = 100 Dim encoderParam as System.Drawing.Imaging.EncoderParameter = new System.Drawing.Imaging.EncoderParameter(System.Dra wing.Imaging.Encoder.Quality, quality) encoderParams.Param(0) = encoderParam Dim arrayICI as ImageCodecInfo() = ImageCodecInfo.GetImageEncoders() Dim jpegICI as ImageCodecInfo Dim x as integer for x = 0 to arrayICI.Length-1 if (arrayICI(x).FormatDescription.Equals("JPEG")) then jpegICI = arrayICI(x) exit for end if next if not jpegICI is nothing then oCanvas.Save(Response.OutputStream, jpegICI, encoderParams) end if ' Now, we only need to send it to the client Response.ContentType = "image/jpeg" oCanvas.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.jpeg) ' Cleanup g.Dispose() oCanvas.Dispose() f1.Dispose() End If End Sub </script> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>E-Flyers</title> </head> <body> <form runat="server"> <div> Company Name: <asp:TextBox runat="server" id="TextBox1"></asp:TextBox><br /> Name: <asp:TextBox runat="server" id="TextBox2"></asp:TextBox><br /> Telephone: <asp:TextBox runat="server" id="TextBox3"></asp:TextBox><br /> Email: <asp:TextBox runat="server" id="TextBox4"></asp:TextBox><br /> <asp:dropdownlist runat="server" id="tColor"> <asp:ListItem Value="black">Black</asp:ListItem> <asp:ListItem Value="white">White</asp:ListItem> <asp:ListItem Value="navy">Navy</asp:ListItem> <asp:ListItem Value="orange">Orange</asp:ListItem> </asp:dropdownlist> </div> <asp:Button runat="Server" id="SubmitButton" Text="Generate Image" /> </form> </body> </html> |
![]() |
| Viewing: ASP Free Forums > Web Design > Web Layout > Image keeps getting ASPX extension |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|