推薦:Asp.Net 無刷新文件上傳并顯示進(jìn)度條的實(shí)現(xiàn)方法及思路相信通過Asp.Net的服務(wù)器控件上傳文件在簡單不過了,通過AjaxToolkit控件實(shí)現(xiàn)上傳進(jìn)度也不是什么難事,為什么還要自己辛辛苦苦來 實(shí)現(xiàn)呢?我并不否認(rèn)拿來主義,只是我個人更喜歡凡是求個所以然。本篇將闡述通過Html,IHttpHandler和 IHttpAsyncHandler實(shí)現(xiàn)文件上傳和上
以下為設(shè)計(jì)步驟:

1、在C# 中連接數(shù)據(jù)庫。如下圖:
2、在項(xiàng)目中添加新建項(xiàng),建立一個數(shù)據(jù)集,并把Categories從服務(wù)器資源列表中拖到這個數(shù)據(jù)集模板中并點(diǎn)擊菜單“生成-生成解決方案”,如下圖:

3、在aspx的webform上放一個ObjectDataSource控件,設(shè)定它的TypeName為剛剛建立的數(shù)據(jù)集類型,用它的向?qū)Ы⒓纯伞?br />4、在aspx的webform上放一個Repeater控件,用它的向?qū)гO(shè)定它的DataSourceID為上面的ObjectDataSource
5、在網(wǎng)頁中設(shè)定它的源碼,即加上<itemTemplate><AlternatingItemTemplate>等模板。如下面的代碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="Repeater.DataSetEmployeesTableAdapters.CategoriesTableAdapter">
</asp:ObjectDataSource>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1"
onitemdatabound="Repeater1_ItemDataBound"
onitemcreated="Repeater1_ItemCreated">
<HeaderTemplate>
類別表
<table border="1"><th>類別ID</th><th>類別名稱</th><th& gt;描述</th><th>圖片</th>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("CategoryID")%></td>
<td>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("CategoryName")%>'></asp:TextBox>
</td>
<td><%#Eval("Description")%></td>
<td><img alt="None" src='<%#Eval("Picture")%>' /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td style="background-color:Blue"><%#Eval("CategoryID")%></td>
<td style="background-color:Blue">
<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("CategoryName")%>'></asp:TextBox>
</td>
<td style="background-color:Blue"><%#Eval("Description")%></td>
<td style="background-color:Blue"><img alt="None" src='<%#Eval("Picture")%>' /></td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
分享:Asp.net獲取客戶端IP常見代碼存在的偽造IP問題探討如果某個網(wǎng)站是通過下面的代碼獲取IP,那么我們只要在Header里隨意設(shè)置HTTP_VIA和X_FORWARDED_FOR,就可以達(dá)到偽造IP的目的 在網(wǎng)卡隨便一搜: Asp.net 客戶端IP 可以搜索到很多頁面,提供的代碼基本都類似于: 復(fù)制代碼 代碼如下: if (Request.ServerVariables[HTTP_VIA]
新聞熱點(diǎn)
疑難解答
圖片精選