TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dibyajyoti Palata
1.5k
275
14.3k
OnUploadedComplete not firing
Apr 27 2020 7:54 AM
<%@ Register Assembly=
"AjaxControlToolkit"
Namespace=
"AjaxControlToolkit"
TagPrefix=
"AjaxToolkit"
%>
<%@ Register Assembly=
"AjaxControlToolkit"
Namespace=
"AjaxControlToolkit"
TagPrefix=
"cc1"
%>
<asp:Content ID=
"Content1"
ContentPlaceHolderID=
"head"
Runat=
"Server"
>
<script type=
"text/javascript"
>
function
AjaxFileUpload1_ClientUploadComplete(sender, e) {
if
(sender._filesInQueue[sender._filesInQueue.length - 1]._isUploaded)
__doPostBack(
"<%= btnViewGallery.UniqueID %>"
,
""
);
// Needed to do a postback to refresh gridview only after all files have been uploaded
}
</script>
</asp:Content>
<asp:Content ID=
"Content2"
ContentPlaceHolderID=
"CommonHeaderContentPlaceHolder"
Runat=
"Server"
>
<asp:ScriptManager ID=
"ScriptManager1"
runat=
"server"
>
</asp:ScriptManager>
<asp:UpdatePanel id=
"UpdatePanel1"
runat=
"server"
>
<ContentTemplate>
<asp:HiddenField ID=
"hdnId"
runat=
"server"
/>
<asp:HiddenField ID=
"hdnType"
runat=
"server"
/>
<div style=
"width:100%;"
>
<div
class
=
"lblPageHeader"
>
Gallery Image Upload
</div>
<div style=
"width:100%;padding:5px;"
>
<span
class
=
"lblClass"
>Gallay Category :</span>
<asp:DropDownList ID=
"ddlGallaryCategory"
runat=
"server"
Width=
"220px"
class
=
"ddlClass"
AutoPostBack=
"true"
OnSelectedIndexChanged=
"fn_loadGallery"
ViewStateMode=
"Enabled"
>
</asp:DropDownList>
</div>
<div style=
"width:100%;"
>
<AjaxToolkit:AjaxFileUpload ID=
"AjaxFileUpload1"
runat=
"server"
IsInFileUploadPostBack=
"true"
mode
OnClientUploadComplete=
"AjaxFileUpload1_ClientUploadComplete"
OnUploadedComplete =
"AjaxFileUpload1_UploadComplete"
/>
</div>
<div style=
"width:100%;"
>
<asp:DataList ID=
"dlImages"
runat=
"server"
RepeatColumns=
"0"
RepeatDirection=
"Horizontal"
BackColor=
"White"
BorderColor=
"#999999"
BorderStyle=
"None"
BorderWidth=
"1px"
CellPadding=
"3"
>
<AlternatingItemStyle BackColor=
"#DCDCDC"
/>
<FooterStyle BackColor=
"#CCCCCC"
ForeColor=
"Black"
/>
<HeaderStyle BackColor=
"#000084"
Font-Bold=
"True"
ForeColor=
"White"
/>
<ItemStyle BackColor=
"#EEEEEE"
ForeColor=
"Black"
/>
<ItemTemplate>
<table border=
"0"
style=
"width:100%;border-bottom-color:#60BAEA;border-top-color:#60BAEA;border-left-color:#60BAEA;border-left-color:#60BAEA;"
cellspacing=
"5"
>
<tr>
<td align=
"center"
style=
"padding:5px;width:100%;"
>
<asp:Image ID=
"img"
runat=
"server"
align=
"center"
BorderStyle=
"Solid"
BorderColor=
"#e0ddd7"
BorderWidth=
"1"
Height=
"50"
ImageUrl=
'<%# DataBinder.Eval(Container.DataItem, "IMAGE_PATH") %>'
/>
<br />
<asp:LinkButton ID=
"RemoveLinkBtn"
runat=
"server"
CommandArgument=
'<%# DataBinder.Eval(Container.DataItem, "IMAGE_ID") %>'
OnCommand=
"RemoveLinkBtn_Command"
>Remove</asp:LinkButton>
</td>
</tr>
</table>
</ItemTemplate>
<SelectedItemStyle BackColor=
"#008A8C"
Font-Bold=
"True"
ForeColor=
"White"
/>
</asp:DataList>
</div>
</div>
<center><asp:Button ID=
"btnViewGallery"
runat=
"server"
Text=
"View Gallery"
OnClick=
"btnViewGallery_Click"
/> </center>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Code :
#region Ajax Upload File
protected
void
AjaxFileUpload1_UploadComplete(
object
sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string
filePath =
string
.Empty;
try
{
string
strID = Session[
"selectedid"
].ToString();
int
compid = Convert.ToInt32(Session[
"COMPID"
]);
filePath = (Server.MapPath(
"~/fileupload/gallery/"
) + Guid.NewGuid() + System.IO.Path.GetFileName(e.FileName));
AjaxFileUpload1.SaveAs(filePath);
string
strFile = filePath.Substring(filePath.LastIndexOf(
"\\"
));
string
strFileName = strFile.Remove(0, 1);
string
strFilePath =
"~/fileupload/gallery/"
+ strFileName;
string
input = Server.MapPath(
"fileupload/gallery/"
) + strFileName;
string
thumb = Server.MapPath(
"fileupload/gallery/thumb/"
) + strFileName;
string
output = Server.MapPath(
"fileupload/gallery/display/"
) + strFileName;
// Load image.
System.Drawing.Image image = System.Drawing.Image.FromFile(input);
Size thumbnailSize = GetImageSize(image, 110);
System.Drawing.Image thumbnail = resizeImage(image, thumbnailSize);
thumbnail.Save(thumb);
Size displaySize = GetImageSize(image, 640);
System.Drawing.Image display = resizeImage(image, displaySize);
display.Save(output);
// Compute thumbnail size, Get thumbnail & Save thumbnail.
/*
Size thumbnailSize = GetImageSize(image,110);
System.Drawing.Image thumbnail = image.GetThumbnailImage(thumbnailSize.Width,
thumbnailSize.Height,
null
, IntPtr.Zero);
thumbnail.Save(thumb);
}
catch
(Exception ex)
{
Response.Write(ex.Message.ToString());
}
}
#endregion
Reply
Answers (
1
)
Data store in database using web api.
The entity type Cargo is not part of the model for the curre