Uploadify v2.1.4を使用して、ASP.Net C#FM4.0を使用して画像をアップロードしています。
このページには他のコントロールもありますが、画像をアップロードするときにUpdatePanel1を自動的に更新して、アップロードされた画像を表示するような機能が必要です。
Default.aspxファイル
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatDirection="Horizontal" >
<ItemTemplate>
<br /><img src='http://test.kashmirsouq.com/ImageUploads/<%# Eval("ImageID") %>' width="100px" height="100px" vspace="2" hspace="2" border="1" />
<br /><asp:LinkButton ID="lnkBtnDeleteImage" CommandArgument='<%# Eval("sno") %>' CommandName="Delete" runat="server">
Delete</asp:LinkButton>
<br />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>"
SelectCommand="SELECT [sno], [ImageID] FROM [User_Images]">
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
ページの例はここにありますtest.kashmirSouq.com
FileUplaad.aspxファイルを呼び出して、jQueryを使用して画像をアップロードしています
<script type="text/javascript">
$(document).ready(function () {
$('#fuFiles').uploadify({
'uploader': 'Scripts/uploadify.swf',
'script': 'FileUploads.aspx',
'cancelImg': 'Scripts/cancel.png',
'auto': 'true',
'multi': 'true',
'fileExt': '*.jpg;*.gif;*.png',
'buttonText': 'Browse...',
'queueSizeLimit': 5,
'simUploadLimit': 2
});
});
</script>
FileUpload.aspx.csファイルで、ファイルをサーバーとデータベースに保存します。FileUpload.aspx.csにある関数saveData()からupdatepanel1を更新できるようにする方法が必要です。
protected int saveData()
{
String strSql = "INSERT INTO HMS_User_Images(ImageID,UserID,ImageCreationDate) ";
strSql += " VALUES ('" + filename + "','123456789', '" + DateTime.Now + "')";
int result = DataProvider.intConnect_Select(strSql);
}
したがって、画像をアップロードすると、グリッドの部分的なページ更新を更新する必要があります。C#を使用してそれを行う方法の例を教えてください
このコードサンプルをどのように実行できるかアドバイスしていただければ幸いです。
よろしく