لمنع تحديت الصفحة قمت بعمل updatepanel
داخلها وضعت fileupload من اجل رفع الملفات
كود رفع الملفات :
'[b]
code upload
If FileUpload1.HasFile = True Then
Dim nom As String = FileUpload1.PostedFile.FileName
Dim mem As IO.Stream = FileUpload1.PostedFile.InputStream
' retourner l'extention du fichier
Dim Extention As String = IO.Path.GetExtension(FileUpload1.FileName)
' retourner la du fichier
Dim taille As Integer = FileUpload1.PostedFile.ContentLength
If taille <= 900000 Then
If Extention = ".rar" Or Extention = ".txt" Or Extention _
= ".pdf" Or Extention = ".PDF" Or Extention = ".JPG" Or Extention = ".jpg" Or _
Extention = ".png" Or Extention = ".PNG" Or Extention = ".jpeg" Or _
Extention = ".JPEG" Or Extention = ".gif" Or Extention = ".GIF" Or _
Extention = ".doc" Or Extention = ".DOC" Or Extention = ".zip" Or _
Extention = ".ZIP" Then
Dim arraybyte As Byte() = New Byte(mem.Length) {}
mem.Read(arraybyte, 0, arraybyte.Length)
' identity is a function witch let to increase the id_sujet(id_thread) automaticly
Dim param As Integer = identity("id_Accessoire", "Accessoires")
cmd.CommandText = "insert into Accessoires(id_Accessoire,nom,myfile,id_sujet) values(@id_Accessoire,@nom,@myfile,@id_sujet)"
cmd.Parameters.AddWithValue("@id_Accessoire", param)
cmd.Parameters.AddWithValue("@nom", nom)
cmd.Parameters.AddWithValue("@myfile", arraybyte)
cmd.Parameters.AddWithValue("@id_sujet", 22)
If cnx.State = ConnectionState.Open Then cnx.Close()
cnx.Open()
cmd.ExecuteNonQuery()
cnx.Close()
lbmsg0.Text = " الملف رفع بنجاح"
lbmsg0.ForeColor = Color.Green
Image1.ImageUrl = "~/images/ok.png"
FileUpload1.Visible = False
Button8.Visible = False
Else
lbmsg0.Text = "(.doc) او (.ZIP) او(.rar) او (.pdf) او (.txt) او (.jpg) او (.png) او (.Gif) يسمح فقط بالامتدادات التالية "
lbmsg0.ForeColor = Color.Red
Image1.ImageUrl = "~/images/fff.gif"
End If
Else
lbmsg0.Text = " حجم الملف لايجب ان يتعدى 800 كيلو "
lbmsg0.ForeColor = Color.Red
Image1.ImageUrl = "~/images/fff.gif"
End If
Else
lbmsg0.Text = "لم تقم بتحديد الملف"
lbmsg0.ForeColor = Color.Red
Image1.ImageUrl = "~/images/fff.gif"
End Ifكما ترون قمت بعمل شرط:
If FileUpload1.HasFile = True Then هنا كود الرفع else lbmsg0.Text = "لم تقم بتحديد الملف" end if
عند الضغط على الزر الدي يحتوي على الكود اعلاه
تضهر لي الرسالة:"لم تقم بتحديد الملف"
عرفت المشكلة وهي عند الضغط على الزر تقوم updatepanel بتحديت محتوياتها بما فيها fileupload هدا ما يفسر تلك الرسالة عند الضغط على الزر
ارجو من السادة الافاضل حل للمشكلة العويصة
و شكرا
:wacko:
