Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a fileupload button and a dropdownlist in the page.

After I select a path in the fileupload button and onselectedIndex change of a dropdown, the path in fileupload button gets cleared off.

I know its because of autopostback property of a dropwn list. But I don't want the path to be cleared in a fileupload on select of a dropdown list..

Any help or suggestion would be greatly appreciated.


Thanks,
Posted
Comments
Raj.rcr 27-Jul-12 16:57pm    
Thanks All... I have got the solution after following all of your suggestions..

Dear Raj,

In design, put your Fileuploader in last of the page, in every postback of dropdownlist, fileuploader will be cleared. so better to put your Fileuploader in last of the page

Thanks
Ashish
 
Share this answer
 
;asp:updatepanel id="up1" runat="server" xmlns:asp="#unknown">
<contenttemplate>

<asp:dropdownlist>
<asp:fileupload>

<asp:button id="btnsubmitresut" runat="server" validationgroup="aa" text="submit" onclick="BtnSubmit_Click" />

<triggers>
<asp:postbacktrigger controlid="btnsubmitresut" />

 
Share this answer
 
v3
AFAIR, you won't be able to show the full path because of security reasons (maximum possible would be filename)

Add this code in your code behind file in selectedchanged event method:
C#
myFileUpload.Attributes.Add("value", fileNameYouWantToShow);



Suggestion:
Keep the fileupload control at the end after all the postbacks, such that once page is submitted you can upload the file from upload control. You won't need to maintain the text in the control via this implementation.
 
Share this answer
 
Hi,
It is clear that on postback of the page your fileupload control is not storing ViewState. So try setting the following properties of your fileupload control:

HTML
EnableViewState="true"
ViewStateMode="Enabled"



This may help you.

--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900