ASP.NET File Upload Progress bar

Fermé
karo1973 - 29 sept. 2011 à 17:53
Bonjour,

Je fais une application en ASP et ASP.net, je suis débutante en asp.net
J'Utilise un script aspx pour uploader un fichier sur le serveur
J'utilise le DLL de la compagnie Obout (FileUpload Progress)

Le fichier doit s'uploader et ensuite, je dois exécuter un script asp qui permet de faire une update des données

Voici le code de la page aspx

<%@Import NameSpace="System.Data.SqlClient" %>
<%@Import NameSpace="System.Collections.Generic" %>
<%@ Register TagPrefix="fup" Namespace="OboutInc.FileUpload" Assembly="obout_FileUpload" %>

<%Dim M_Statut as string
Dim M_user,M_NomUser,M_TypeUser,M_IdCieUser,M_LangueUser,M_access

'*** COOKIE / SESSION ***
If Not Request.Cookies("sessionCLP") Is Nothing Then
M_User = Server.HtmlEncode(Request.Cookies("sessionCLP")("User"))
M_NomUser = Server.HtmlEncode(Request.Cookies("sessionCLP")("NomUser"))
M_TypeUser = Server.HtmlEncode(Request.Cookies("sessionCLP")("TypeUser"))
M_IdCieUser = Server.HtmlEncode(Request.Cookies("sessionCLP")("IdCie"))
M_LangueUser = Server.HtmlEncode(Request.Cookies("sessionCLP")("Langue"))
M_access = Server.HtmlEncode(Request.Cookies("sessionCLP")("Access"))
Else
Response.Redirect ("erreur_session.asp")
End If
'Response.Write ("<font color="&"#FFFFFF"&">" & M_LangueUser & "</font><BR>")
'*** FIN COOKIE / SESSION ***
%>
<html>
<head>
<title>Upload</title>
<link rel="stylesheet" href="example_styles/style.css" />

<script runat="server" language="vb">
Public Sub Page_Load(sender As Object, e As EventArgs)
If Page.IsPostBack Then
Dim files As HttpFileCollection = Page.Request.Files
Dim i As Integer
Dim M_TempFile,M_Fichier as String

uploadedFiles.Text = ""

For i=0 To files.Count-1 Step 1
Dim file As HttpPostedFile = files(i)

M_TempFile = "Excel_File.xls"
M_Fichier = file.FileName.Substring(file.FileName.LastIndexOf("\")+1)
file.SaveAs(MapPath("\CLP\Import\"+M_Fichier))

If file.FileName.Length >0 Then
If uploadedFiles.Text.Length = 0 Then
uploadedFiles.Text += "<b>Successfully uploaded files:</b><table border=0 cellspacing=0>"
End If
uploadedFiles.Text += "<tr><td class='option2'>"+file.FileName.Substring(file.FileName.LastIndexOf("\")+1)+"</td><td style='font:11px Verdana;'>  "+file.ContentLength.ToString()+" bytes</td></tr>"
End If
Next

If uploadedFiles.Text.Length=0 Then
uploadedFiles.Text = "no files"
Else
uploadedFiles.Text+= "</table>"
End If
End If
End Sub
</script>

<script type="text/JavaScript">
function Rejected(fileName, size, maxSize){
var addMessage = (maxSize >= 0)?("exceeds "+maxSize+" bytes"):("-- session lost");
alert("File "+fileName+" is rejected \nIts size ("+size+" bytes) "+addMessage);
}
function ClearedFiles(fileNames){
alert("NOT Excel file:\n\n"+fileNames);
}

function Clear()
{
document.getElementById("<%= uploadedFiles.ClientID %>").innerHTML = "";
}

function ShowName(M_Fichier)
{
alert("ok");
document.getElementById("myFile1").innerHTML = "toto";
}

function Integrer()
{
document.form1.action="IntegrerFormation.asp?idPays=1"
document.form1.submit()
}

</script>

</head>

<body bgcolor="#615A2C" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="800" height="467">
<tr>
<td background="Image/left_shading.png" height="73"> </td>
<td background="Image/entete_small.jpg" width="772" height="73">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="95%">
<tr>
<td width="50%">
<img border="0" src="Image/cocoa-logo.png" width="200" height="39"></td>
<td width="50%">
<p align="right">
<a onmouseover="var img=document['fpAnimswapImgFP7'];img.imgRolln=img.src;img.src=img.lowsrc?img.lowsrc:img.getAttribute?img.getAttribute('lowsrc'):img.src;" onmouseout="document['fpAnimswapImgFP7'].src=document['fpAnimswapImgFP7'].imgRolln" href="CLP.html">
<img border="0" src="bouton/disconnect.png" id="fpAnimswapImgFP7" name="fpAnimswapImgFP7" dynamicanimation="fpAnimswapImgFP7" lowsrc="bouton/disconnect_roll.png" width="77" height="19"></a></td>
</tr>
</table>
</center>
</div>
</td>
<td background="Image/right_shading.png" height="73"> </td>
</tr>
<tr height="23">
<td background="Image/left_shading.png"> </td>
<td valign="top">
<p align="left">
<a onmouseover="var img=document['fpAnimswapImgFP1'];img.imgRolln=img.src;img.src=img.lowsrc?img.lowsrc:img.getAttribute?img.getAttribute('lowsrc'):img.src;" onmouseout="document['fpAnimswapImgFP1'].src=document['fpAnimswapImgFP1'].imgRolln" href="clp.asp"><img border="0" src="Menu/MENU_HOME.png" id="fpAnimswapImgFP1" name="fpAnimswapImgFP1" dynamicanimation="fpAnimswapImgFP1" lowsrc="Menu/MENU_HOME_ROLL.png" width="197" height="24"></a></td>
<td background="image/right_shading.png"> </td>
</tr>
<tr>
<td background="Image/left_shading.png" height="222"> </td>
<td height="552" bgcolor="#FFFFFF" VALIGN="TOP">
<!--- DEBUT - CENTRE DE L'ÉCRAN --->
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%">
<tr>
<td width="50%" height="40" VALIGN="TOP">
<!--- Section UPLOAD --->
<!--- <form ACTION="IntegrerFormation.asp?idPays=1" METHOD="POST"> --->
<form runat="server" id="form1">
<%Dim SQL1 as String%>
<TABLE WIDTH="450" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD WIDTH="150"><font face="Arial"><span style="font-size:11pt;">Year :</span></font></TD>
<TD WIDTH="300"><Select name="T_Year"><option value="0:All Year">All Year</option>
<%Dim oConnection1 As New SqlConnection()
oConnection1.ConnectionString = ConfigurationSettings.AppSettings("SqlServer")
oConnection1.Open()
sql1 = "SELECT id,Nom FROM Annee ORDER BY Nom"
Dim command1 As New SqlCommand(SQL1, oConnection1)
Dim Rs As SqlDataReader = command1.ExecuteReader()
Do While rs.read()%>
<option value="<%=rs(1)%>:<%=rs(1)%>"><%=rs(1)%></option>
<%Loop
rs.close
oConnection1.dispose%></select></TD>
</TR>
<TR>
<TD WIDTH="150" vAlign="Top"><font face="Arial"><span style="font-size:11pt;">Training :</span></font></TD>
<TD WIDTH="300"><Select name="T_Training"><option value="0:All Training">All Training</option>
<%Dim oConnection As New SqlConnection()
oConnection.ConnectionString = ConfigurationSettings.AppSettings("SqlServer")
oConnection.Open()
sql1 = "SELECT id_TypeFormation,DescA FROM TypeFormation WHERE (id_TypeFormation <> 0) ORDER BY DescA"
Dim command2 As New SqlCommand(SQL1, oConnection)
Dim Rs1 As SqlDataReader = command2.ExecuteReader()
Do While rs1.read()%>
<option value="<%=rs1(0)%>:<%=rs1(1)%>"><%=rs1(1)%></option>
<%Loop
rs1.close
oConnection.dispose%></select></TD>
</TR>
<TR>
<TD WIDTH="150"><font face="Arial"><span style="font-size:11pt;">Technical partner:</span></font></TD>
<TD WIDTH="300"><Select name="T_Year"><option value="0:All Year">All Technical partner</option>
<option value="STCP/IITA">STCP/IITA</option><option value="TNS">TNS</option>
<option value="GIZ">GIZ</option><option value="ACDI VOCA">ACDI VOCA</option>
<option value="SOCODEVI">SOCODEVI</option></select></TD>
</TR>
<TR>
<TD WIDTH="150" valign="Top"><font face="Arial"><span style="font-size:11pt;">File to upload : </span></font></TD>
<TD WIDTH="300"><input type="file" name="myFile1" id="myFile1">
<input type="submit" value="submit" name="mySubmit" /></TD>
</TR>
<TR>
<TD WIDTH="450" ColSpan="2" valign="Top" ALIGN="Center">
<a onmouseover="var img=document['fpAnimswapImgFP6'];img.imgRolln=img.src;img.src=img.lowsrc?img.lowsrc:img.getAttribute?img.getAttribute('lowsrc'):img.src;" onmouseout="document['fpAnimswapImgFP6'].src=document['fpAnimswapImgFP6'].imgRolln" href="javascript:Integrer()">
<img border="0" src="bouton/submit.png" id="fpAnimswapImgFP6" name="fpAnimswapImgFP6" dynamicanimation="fpAnimswapImgFP6" lowsrc="bouton/submit.png" width="46" height="19"></a></TD>
</TR>
</TABLE>
<BR>
<fup:FileUploadProgress
OnClientProgressStarted = "Clear"
OnClientProgressStopped = "ShowName"
OnClientFileCleared = "ClearedFiles"
ShowUploadedFiles = "true"
runat = "server">
<AllowedFileFormats>
<fup:Format Ext="xls" />
</AllowedFileFormats>
</fup:FileUploadProgress>
<fup:StatusPanel runat="server">
<asp:Label runat="server" id="uploadedFiles" Text="" />
</fup:StatusPanel>
</form>
<!--- FIN Section UPLOAD --->
</td>
<td width="50%" height="552" Valign="Top" style="border-left: 1px solid #615A2C; border-right-width: 1; border-top-width: 1; border-bottom-width: 1"></td>
</tr>
</table>
</div>
</td>
<td background="Image/right_shading.png" height="552"> </td>
</tr>
<tr>
<td background="Image/left_shading.png" height="71"> </td>
<td background="Image/entete.png" height="71">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="95%">
<tr>
<td width="8%">
<img border="0" src="image/bottines.png" width="50" height="45"></td>
<td width="42%"><font face="Verdana" size="1" color="#FFFFFF">Map Track Solutions © 2011</font></td>
<td width="50%"> </td>
</tr>
</table>
</center>
</div>
</td>
<td background="Image/right_shading.png" height="71"> </td>
</tr>
</table>
</center>
</div>
</body>
</html>

je ne suis pas capable de lire les info de la form et d'exécuter le script asp
merci de votre aide