PC Review


Reply
Thread Tools Rate Thread

AutoPostBAck problem

 
 
=?Utf-8?B?dGFsdmFybw==?=
Guest
Posts: n/a
 
      16th Jun 2006
HELP!!!!

I have a ListBox control, when one of the item is clicked I am using a
series of porperties and methos for Reponse class in order to allow download
diff files. The problem is that it doesn't matter what is clicked after a
item within the listBox is cliecked always the SelectedIndexChanged method
for the listBox is executed. Here is the code:

private void pdfListBox_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
pdfListBox.Enabled = false;
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.Clear();
Response.AppendHeader("Content-Disposition",
"attachment;Filename=Report.pdf");
Response.TransmitFile(pdfListBox.SelectedValue);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}

Any help wil lbe greatlly appreciated.
 
Reply With Quote
 
 
 
 
Jim Nugent
Guest
Posts: n/a
 
      16th Jun 2006
In news:5C15A6E2-7EAF-4F0D-9C22-(E-Mail Removed),
talvaro <(E-Mail Removed)> wrote:
> HELP!!!!
>
> I have a ListBox control, when one of the item is clicked I am using a
> series of porperties and methos for Reponse class in order to allow
> download diff files. The problem is that it doesn't matter what is
> clicked after a item within the listBox is cliecked always the
> SelectedIndexChanged method for the listBox is executed. Here is the
> code:
>
> private void pdfListBox_SelectedIndexChanged(object sender, EventArgs
> e) {
> try
> {
> pdfListBox.Enabled = false;
> Response.ClearHeaders();
> Response.ContentType = "application/pdf";
> Response.Clear();
> Response.AppendHeader("Content-Disposition",
> "attachment;Filename=Report.pdf");
> Response.TransmitFile(pdfListBox.SelectedValue);
> HttpContext.Current.ApplicationInstance.CompleteRequest();
> }
>
> Any help wil lbe greatlly appreciated.


I am not sure what your question is. The SelectedIndexChanged method will
always be executed.
If you are not getting proper file names out, it might be because each
ListItem contains both value and text. Depending on how you are loading the
listbox, value may be the 'index' not the displayed file name.Try this:

string filename = pdfListBox.SelectedItem.Text;
Response.TransmitFile(filename);

BTW the reason I broke it into two statements is that way you can use the
debugger to watch the string filename.
--
Jim
"Remember, an amateur built the Ark; professionals built the Titanic."



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdownlist autopostback problem andy Microsoft ASP .NET 0 28th Mar 2007 12:02 PM
Gridview / autopostback problem postings@alexshirley.com Microsoft ASP .NET 1 31st Mar 2006 04:24 PM
Problem with autopostback and .Net 2005 Darcy810 Microsoft ASP .NET 0 15th Feb 2006 02:28 PM
Problem with autopostback on webcontrols Sean Chapman Microsoft ASP .NET 1 21st Jan 2006 03:22 AM
Problem with Autopostback Jesse Microsoft ASP .NET 4 17th Jul 2003 08:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:44 AM.