views:

227

answers:

2

Hello,

I create a list with upload files (just .txt files),

blListDocs.Items.Clear();  

            string pn = Server.MapPath("../Uploads/Data");  

            string pathToWebAppRoot = Request.ApplicationPath;  
            string pathToFolder = "/Uploads/Data/";  
            string urlPath = pathToWebAppRoot + pathToFolder; 

            String[] fileList = Directory.GetFiles(pn);

            for (int i = 0; i < fileList.Length - 1; i++)  
            {  
              ListItem li = new ListItem();  
              li.Text = Path.GetFileName(fileList[i]);  
              li.Value = urlPath + li.Text;  
              blListDocs.Items.Add(li);  
            }

Now, when I click one item link, the file's content is opening in another Web Page, but I'd like to read clicked file's content in control

<asp:TextBox ID="txtReadDocs" runat="server" TextMode="MultiLine" Rows="4"></asp:TextBox>

Thank You so much!!

+1  A: 

jQuery

function onLinkClick(link) {      
    $.get(link.href, '', function(data) {
        $("input[id*=txtReadDocs]").val(data);
    }
}
ChaosPandion
I'm sorry, but I have to do this without javascript, just C#, it is possible ?
Alexander Corotchi
Why such a restriction?
ChaosPandion
+1  A: 

If you want a server side implementation link the url of your page to the same page and append a querystring parameter specifying which text file you want...then you have full access to read the text file and stuff it into your control. Otherwise use the jQuery answer listed by @ChaosPandion

Andrew Siemer