Ajax AsyncFileUpload contains Filename Every time
- by Kartik Patel
I have used the Ajax AsyncFileUpload.I have three field.
1.Name
2.Asynchronous File Upload
3.Description
4.Save buttton
when I click on Save new Record created.after creating new record when i enter all above details except select the Asynchronous File Upload.However when i click on Save button the Asynchronous File Upload contains the before Asynchronous upload File Name inspite of i didnt select the File from File Upload...How its possible getting confused..
My code is like this i have used master page.
<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
<script type="text/javascript" language="javascript">
function UploadComplete() {
document.getElementById('<%=lblmsg.ClientID %>').innerHTML = "Image Uploaded Successfully.";
}
function UploadError() {
document.getElementById('<%=lblmsg.ClientID %>').innerHTML = "Image Upload Failed.";
}
</script>
<table>
<tr>
<td colspan="2">
<h1 style="color: #008000">
Add Project Details</h1>
</td>
</tr>
<tr>
<td align="left">
<asp:Label ID="lblProjectName" runat="server" Text="Project Name" Font-Bold="true"></asp:Label>
</td>
<td align="left">
<asp:TextBox ID="txtProjectName" runat="server" MaxLength="50" Width="150px" ValidationGroup="Save"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvprojectname" runat="server" Text="Project Name is Required."
ErrorMessage="Project Name is Required." ControlToValidate="txtProjectName" ForeColor="Red"
ValidationGroup="Save"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="left">
<asp:Label ID="lblselectimage" runat="server" Text="Select Image" Font-Bold="true"></asp:Label>
</td>
<td align="left">
<table>
<tr>
<td>
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
<cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server"
OnClientUploadComplete="UploadComplete" OnClientUploadError="UploadError" CompleteBackColor="White"
Width="350px" UploaderStyle="Traditional" UploadingBackColor="#CCFFFF" ThrobberID="imgLoad"
OnUploadedComplete="fileuploadComplete" ClientIDMode="AutoID" EnableViewState="true"/>
</td>
<td>
<asp:Image ID="imgUpload" runat="server" Width="50px" Height="50px" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Image ID="imgLoad" runat="server" ImageUrl="~/Images/loading-gif-animation.gif"
Width="50px" Height="50px" />
<asp:Label ID="lblmsg" runat="server" ForeColor="Blue" Font-Bold="true"></asp:Label>
</td>
</tr>
<tr>
<td align="left">
<asp:Label ID="lblDescription" runat="server" Text="Description" Font-Bold="true"></asp:Label>
</td>
<td align="left">
<asp:TextBox ID="txtDescription" runat="server" MaxLength="1000" Width="300" TextMode="MultiLine"
ValidationGroup="Save" Height="100px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RfvtxtDescription" runat="server" Text="Project Description is Required."
ErrorMessage="Project Description is Required." ControlToValidate="txtDescription"
ForeColor="Red" ValidationGroup="Save"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td align="left">
<asp:ImageButton ID="btnsave" runat="server" ImageUrl="~/Images/Save.jpg" OnClick="btnSave_Click"
Height="37px" ValidationGroup="Save" />
</td>
</tr>
</table>