وقتی فایل اپلود در داخل اپدیت پنل استفاده میکنم از کار میفته و هیچ پست بکی نداره باید جیکار کنم
<asp:UpdatePanel runat="server" id="UpdatePanel1"> <ContentTemplate> <asp:FileUpload runat="server" id="FileUpload1" /> <asp:Button runat="server" id="btnSubmit" Text="Upload" /> </ContentTemplate> <Triggers> <asp:postbacktrigger ControlID="btnSubmit" /> </Triggers> </asp:UpdatePanel>
با خطا مواجه میشم
میگه فایل آپلود خالیه
در صورتی که فایل مورد نظر هم انتخاب میکنم
راه حلش چیه؟
سرچ کنید use fileupload in updatepanel
سرچ کردم همش همین کد که شما گذاشتین هست
مشکل از کدی که نوشتم نیست؟
int Parent_file; if (lbl_Name_file.Text == "".Trim()) { Parent_file = 0; div_main_Filemanager.Visible = true; } else { Parent_file = Convert.ToInt32(lbl_ID_File.Text); div_AdditemFolder.Visible = true; } string Name_file = ""; string filename = Path.GetFileName(F_pic.PostedFile.FileName); string extension = Path.GetExtension(filename); string contentType = F_pic.PostedFile.ContentType; HttpPostedFile file = F_pic.PostedFile; byte[] document = new byte[file.ContentLength]; file.InputStream.Read(document, 0, file.ContentLength); if (extension != ".jpg" && extension != ".png") { bellsuccess.Visible = false; Div_bell.Visible = belldanger.Visible = true; sp_danger.InnerText = "این نوع فایل پشتیبانی نمی شود فایل های مجاز : png. و jpg. "; return; } else { string savepath = Server.MapPath("~\\Cr-Content/Filemanager" + lbl_Name_file.Text); string savefile; savefile = Path.Combine(savepath, F_pic.FileName); if (F_pic.HasFile) { if (!File.Exists(savefile)) Name_file = F_pic.FileName; F_pic.SaveAs(savefile); } } string url_file = "/Cr-Content/Filemanager" + lbl_Name_file.Text + "/" + Name_file; string icon_file = "fa fa-picture-o"; DAL.FileManager insert = new DAL.FileManager(); insert.Name_file = Name_file; insert.Parent_file = Parent_file; insert.icon_file = icon_file; insert.url_file = url_file; insert.Insert(); Div_bell.Visible = bellsuccess.Visible = true; belldanger.Visible = false; Sp_success.InnerText = "تصویر با موفقیت آپلود شد"; M_filemanager.ActiveViewIndex = -1; SqlDataSource Loadcat = new SqlDataSource(); Loadcat = DAL.categori.data_source("SELECT * FROM [Filemanager] WHERE Parent_file='" + Parent_file + "' ORDER BY [Name_file] DESC"); Lis_File.DataSource = Loadcat; Lis_File.DataBind();
باید کدتون رو Trace کنید
من مشکلی ندیدم
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)