Click here to Skip to main content
15,888,600 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Showing error message Pin
Brij2-Nov-10 2:36
mentorBrij2-Nov-10 2:36 
GeneralRe: Showing error message Pin
RaviRanjanKr2-Nov-10 3:06
professionalRaviRanjanKr2-Nov-10 3:06 
Questioncannot do add to cart function Pin
setengah1-Nov-10 14:53
setengah1-Nov-10 14:53 
AnswerRe: cannot do add to cart function Pin
T M Gray2-Nov-10 4:33
T M Gray2-Nov-10 4:33 
GeneralRe: cannot do add to cart function Pin
Fayu9-Nov-10 4:44
Fayu9-Nov-10 4:44 
QuestionDataset or ado.net Pin
future38391-Nov-10 3:35
future38391-Nov-10 3:35 
AnswerRe: Dataset or ado.net Pin
Not Active1-Nov-10 4:38
mentorNot Active1-Nov-10 4:38 
Questionhelp with url rewrite... Pin
swornavidhya_m31-Oct-10 23:09
swornavidhya_m31-Oct-10 23:09 
I have to do an module program which downloads pdf files in the client side. Currently, when users download the file, the url of the downloaded file is viewed by the user.

Modification instructed:
1. In the page where the file download is requested, the url of the downloaded file is viewed in the status bar of that web page. Modification is that the status bar should not display the url of the downloaded file. -- This had been corrected and the code has modified accordingly. It is done correctly only for the first page. Blinks how to process this for the second page..

2. Currently, the call for the download page is given along with the filename of the user request. The filename is passed as the querystring. Modification needed is that the url should get rewritten as "~/download.aspx" instead of "~/download.aspx?<filename>".

I came across using "urlrewriter". But don't know how to implement since i feel little confused with the code examples in net.

I'm placing my code for ur assistance. I'm not using webconfig file also.
old try pdf.aspx
****************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="old try pdf.aspx.cs" Inherits="old_try_pdf" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Try PDF - Download</title>
    <style>
        .link_text
        {
	        font-family:Tahoma;
	        font-size:10px;
	        color:#1d5296;
	        text-decoration:none;
        }

        .link_text A
        {
	        font-family:Tahoma;
	        font-size:11px;
	        color:#1d5296;
	        text-decoration:underline;	
        }

        .link_text A:hover
        {
	        color:#ff000c;
	        text-decoration:underline;
        }

        .link_text A:active
        {
	        color:#ff000c;
	        text-decoration:underline;
        }
        
        .bullets
        {
	        background-image:url(Bullet.gif);	
	        background-position:center;
	        width:10px;
	        height:10px;
	        display:table-cell;		
	        vertical-align:top;
	        background-repeat:no-repeat;
        }
        
        .display_cell
        {
	        border:solid 1px #e6e7e8;
	        display:table-cell;
	        width:355px;
        }

    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <table>
                <tr>
                    <td class='display_cell'>
                        <asp:Panel runat=server ID="pnl_pdf"></asp:Panel>
                    </td>
                </tr>
            </table>
            
        </div>
    </form>
</body>
</html>


old try pdf.aspx.cs
*******************
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class old_try_pdf : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Table tb_currency = new Table();
        tb_currency.Width = 355;
        TableRow tr_currency = new TableRow();
        TableCell tc_currency = new TableCell();
        Image img_currency = new Image();
        HyperLink hlk = new HyperLink();

        foreach (string fnames in Directory.GetFiles(@"~\Link 2 Download\pdf"))
        {
            string fname = null;

            tr_currency = new TableRow();

            tc_currency = new TableCell();
            tc_currency.CssClass = "bullets";
            tr_currency.Cells.Add(tc_currency);

            tc_currency = new TableCell();
            tc_currency.HorizontalAlign = HorizontalAlign.Left;
            tc_currency.CssClass = "link_text";
            hlk = new HyperLink();
            hlk.Target = "_blank";

            fname = Path.GetFileNameWithoutExtension(fnames);

            hlk.Text = fname;
            hlk.Attributes.Add("onMouseOver", "javascript:window.status=''; return true;");
            hlk.Attributes.Add("onMouseOut", "javascript:window.status=''; return true;");
            hlk.Attributes.Add("onClick", "javascript:window.status=''; return true;");
            hlk.NavigateUrl = "~/Old download_pdf.aspx?fn=" + fname;
            tc_currency.Controls.Add(hlk);
            tr_currency.Cells.Add(tc_currency);

            tb_currency.Rows.Add(tr_currency);
        }

        pnl_pdf.Controls.Clear();
        pnl_pdf.Controls.Add(tb_currency);

    }
}


Old download_pdf.aspx
*********************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Old download_pdf.aspx.cs" Inherits="Old_download_pdf" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>




Old download_pdf.aspx.cs
************************
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;


public partial class Old_download_pdf : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Create a message string
        string strMessage = "Wait.... File is downloading....";
        // Register startup script to show a message in status bar
        this.RegisterStartupScript("SetStatusText", "<script>window.status='" + strMessage + "';</script>");

        if (Request.QueryString.Count > 0)
        {
            string fn = Request.QueryString.Get(0).ToString();

            string spath = @"~\pdf\" + fn + ".pdf";
            Response.ClearContent(); 
            Response.ClearHeaders();
            Response.ContentType = "application/pdf";
            //Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment; filename=my_test.pdf");
           
            Response.TransmitFile(spath);
            Response.End();
        }       

    }
}


Even using register startup variable, in Old_download_pdf.aspx, it is showing the downloaded file url path in status bar of the page Old_download_pdf.aspx. Also we have to rewrite the url from "~/Old download_pdf.aspx?fn=<filename>" as simply "~/Old download_pdf.aspx".

When i tried using a hidden variable, i failed in setting the value of the hidden field during the click event of the dynamically creating hyperlink control.


How to complete this? Thanks in advance.

Regards,
M.Sworna Vidhya
QuestionAjax with VS 2005 Pin
AndieDu31-Oct-10 20:51
AndieDu31-Oct-10 20:51 
QuestionHyper Link in datagrid to download a file Pin
<<Tash18>>31-Oct-10 20:38
<<Tash18>>31-Oct-10 20:38 
AnswerRe: Hyper Link in datagrid to download a file Pin
Not Active1-Nov-10 2:14
mentorNot Active1-Nov-10 2:14 
GeneralRe: Hyper Link in datagrid to download a file Pin
<<Tash18>>1-Nov-10 19:00
<<Tash18>>1-Nov-10 19:00 
QuestionCopy Multiple File on Client Machine Pin
raushan_931-Oct-10 20:00
raushan_931-Oct-10 20:00 
QuestionASP.net VB Pin
Xinxen31-Oct-10 19:50
Xinxen31-Oct-10 19:50 
Questionbest way to save news? Pin
Jassim Rahma31-Oct-10 4:40
Jassim Rahma31-Oct-10 4:40 
AnswerRe: best way to save news? Pin
Brij31-Oct-10 4:53
mentorBrij31-Oct-10 4:53 
Questionlosing the focud!! Pin
Jassim Rahma31-Oct-10 4:36
Jassim Rahma31-Oct-10 4:36 
QuestionHow do I integrate my asp.net website with other websites...(similar to Facebook Connect)? Pin
Nada Adel31-Oct-10 1:45
Nada Adel31-Oct-10 1:45 
Question500-inernal server error . Pin
Davood Riazi30-Oct-10 22:33
Davood Riazi30-Oct-10 22:33 
AnswerRe: 500-inernal server error . Pin
Keith Barrow31-Oct-10 4:37
professionalKeith Barrow31-Oct-10 4:37 
AnswerRe: 500-inernal server error . Pin
Brij31-Oct-10 4:47
mentorBrij31-Oct-10 4:47 
Questionprint a mobile webpage Pin
behzadcp30-Oct-10 19:28
professionalbehzadcp30-Oct-10 19:28 
Questiondatabse Pin
sheemap30-Oct-10 8:26
sheemap30-Oct-10 8:26 
AnswerRe: databse Pin
Karthik. A30-Oct-10 16:08
Karthik. A30-Oct-10 16:08 
GeneralRe: databse Pin
sheemap31-Oct-10 4:17
sheemap31-Oct-10 4:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.