I am using AsyncFileUpload to upload files on a vb.net (4.0) page. The user selects the file they want to upload. The user then enters some other information on the form and then clicks save to begin processing of the data which causes a postback. When the
postback happens the path and filename dissappear from the textbox for the upload object. How can I keep it from losing its path? I have spent a good deal of time on this and have tried several things without any luck. I have placed it inside of an update
panel and set updatemode to conditional and that didnt work. I have tried some javascripting as well but it always seems to apply only to when the file gets asynchronioulsy uploaded not when the page postback. Here is what my code looks like: Any help would
be greatly appreciated.
<script type="text/javascript">
function fillCell(row, cellNumber, text) {
var cell = row.insertCell(cellNumber);
cell.innerHTML = text;
cell.style.borderBottom = cell.style.borderRight = "solid 1px #aaaaff";
}
function addToClientTable(name, text) {
var table = document.getElementById("<%= clientSide.ClientID %>");
var row = table.insertRow(0);
fillCell(row, 0, name);
fillCell(row, 1, text);
}
function uploadError(sender, args) {
addToClientTable(args.get_fileName(), "<span style='color:red;'>" + args.get_errorMessage() + "</span>");
}
function uploadComplete(sender, args) {
//alert("hi");
var contentType = args.get_contentType();
var text = args.get_length() + " bytes";
if (contentType.length > 0) {
text += ", '" + contentType + "'";
}
addToClientTable(args.get_fileName(), text);
}
</script>
I noticed your html didn't have a lot of closing tags, so I copied and pasted into a test project. I then fixed all the tags and came up with (which my need modified by you):
It hits the javascript like I would expect and after full postback the text in my "txtStuff" is still there, as well as the file I selected with a green bar showing a successful upload.
I learn by helping others. I may not always be correct but my intentions are good. If my answer helps please mark it as so.
In the upload text area where it shows the path, the file path stayed after your clicked a save button or postback? I am not talking about it loading once you have selected the file. I do understand that it loads right then but my users fill out more information
down the page before they get to the bottom of the page and click a "save" button which sends data over to a database and causes a postback.
I didnt paste in all of my code... there was too much to paste in. My HTML code does have all of its ending tags.
Thanks... I have read the properties on it and everything. Just trying to see if there is a way to keep the file path listed even after a postback is done(clicking a save button). The box clears.
crocboy25
Member
60 Points
94 Posts
AsyncFileUpload Question
Jul 06, 2012 02:18 PM|LINK
Hello Group,
I am using AsyncFileUpload to upload files on a vb.net (4.0) page. The user selects the file they want to upload. The user then enters some other information on the form and then clicks save to begin processing of the data which causes a postback. When the postback happens the path and filename dissappear from the textbox for the upload object. How can I keep it from losing its path? I have spent a good deal of time on this and have tried several things without any luck. I have placed it inside of an update panel and set updatemode to conditional and that didnt work. I have tried some javascripting as well but it always seems to apply only to when the file gets asynchronioulsy uploaded not when the page postback. Here is what my code looks like: Any help would be greatly appreciated.
<script type="text/javascript">
function fillCell(row, cellNumber, text) {
var cell = row.insertCell(cellNumber);
cell.innerHTML = text;
cell.style.borderBottom = cell.style.borderRight = "solid 1px #aaaaff";
}
function addToClientTable(name, text) {
var table = document.getElementById("<%= clientSide.ClientID %>");
var row = table.insertRow(0);
fillCell(row, 0, name);
fillCell(row, 1, text);
}
function uploadError(sender, args) {
addToClientTable(args.get_fileName(), "<span style='color:red;'>" + args.get_errorMessage() + "</span>");
}
function uploadComplete(sender, args) {
//alert("hi");
var contentType = args.get_contentType();
var text = args.get_length() + " bytes";
if (contentType.length > 0) {
text += ", '" + contentType + "'";
}
addToClientTable(args.get_fileName(), text);
}
</script>
<asp:UpdatePanel runat="server" ID="UpdatePanelEditNarrative" UpdateMode="Conditional">
<ContentTemplate>
<table width="700px" border="0" cellpadding="2">
<colgroup>
<col width="13%"/>
<col width="87%" />
<tr>
<td valign="middle">
<cc10:AsyncFileUpload OnClientUploadError="uploadError" OnClientUploadComplete="uploadComplete"
runat="server" ID="AsyncFileUpload1" Width="400px" UploaderStyle="Modern"
UploadingBackColor="#CCFFFF" ThrobberID="myThrobber"/>
<asp:Label runat="server" ID="myThrobber" style="display:none;" >
<img align="middle" alt="" src="" />
</asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
......
Further down the page there is a button that causes a postback.
cornball76
Participant
1126 Points
210 Posts
Re: AsyncFileUpload Question
Jul 06, 2012 03:16 PM|LINK
I noticed your html didn't have a lot of closing tags, so I copied and pasted into a test project. I then fixed all the tags and came up with (which my need modified by you):
<table width="700px" border="0" cellpadding="2"> <tr> <td valign="middle"> <asp:asyncfileupload OnClientUploadError="uploadError" OnClientUploadComplete="uploadComplete" runat="server" ID="AsyncFileUpload1" Width="400px" UploaderStyle="Modern" UploadingBackColor="#CCFFFF" ThrobberID="myThrobber"/> </td> </tr> <tr> <td> <asp:Label runat="server" ID="myThrobber" style="display:none;" > <img align="middle" alt="" src="" /> </asp:Label> </td> </tr> <tr> <td> <asp:TextBox runat="server" ID="txtStuff"></asp:TextBox> </td> </tr> </table> It hits the javascript like I would expect and after full postback the text in my "txtStuff" is still there, as well as the file I selected with a green bar showing a successful upload.
crocboy25
Member
60 Points
94 Posts
Re: AsyncFileUpload Question
Jul 06, 2012 05:04 PM|LINK
In the upload text area where it shows the path, the file path stayed after your clicked a save button or postback? I am not talking about it loading once you have selected the file. I do understand that it loads right then but my users fill out more information down the page before they get to the bottom of the page and click a "save" button which sends data over to a database and causes a postback.
I didnt paste in all of my code... there was too much to paste in. My HTML code does have all of its ending tags.
cornball76
Participant
1126 Points
210 Posts
Re: AsyncFileUpload Question
Jul 06, 2012 06:31 PM|LINK
Sorry I misunderstood the question.
Doing as you asked I see that it clears out.
This points to it being an unresolved bug.
http://ajaxcontroltoolkit.codeplex.com/workitem/26729
crocboy25
Member
60 Points
94 Posts
Re: AsyncFileUpload Question
Jul 06, 2012 07:17 PM|LINK
ok... thanks for helping with this.
chetan.sarod...
All-Star
65759 Points
11153 Posts
Re: AsyncFileUpload Question
Jul 09, 2012 03:21 AM|LINK
Use AjaxFileUpload
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AjaxFileUpload/AjaxFileUpload.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
crocboy25
Member
60 Points
94 Posts
Re: AsyncFileUpload Question
Jul 09, 2012 11:50 AM|LINK
Thanks... I have read the properties on it and everything. Just trying to see if there is a way to keep the file path listed even after a postback is done(clicking a save button). The box clears.