ip添加頁是用了一個ListBox
而在其他的頁上則直接用當前IP對比數據庫中的IP
限制IP添加頁HTML代碼
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ip
<!DOCTYPE html PUBLIC "
<html xmlns="
<head runat="server">
<title>無標題頁</title>
<link href="
</head>
<body>
<form id="form
<div>
<asp:SqlDataSource ID="SqlDataSource
PRoviderName="<%$ ConnectionStrings:book
</asp:SqlDataSource>
<table align="center" style="border
<tr>
<td rowspan="
<asp:ListBox ID="iplxb" runat="server" DataSourceID="SqlDataSource
DataValueField="ip" Height="
<td style="width:
填寫標准的IP地址到左下文本框裡面
<asp:RegularExpressionValidator ID="RegularExpressionValidator
Display="Dynamic" ErrorMessage="IP地址格式不正確" ValidationExpression="([
</tr>
<tr>
<td style="width:
<asp:LinkButton ID="LinkButton
</tr>
<tr>
<td style="width:
<asp:TextBox ID="iptb" runat="server" Width="
<td style="width:
<asp:Button ID="Button
</tr>
</table>
</div>
</form>
</body>
</html>
限制IP添加頁CS代碼
using System;
using System
using System
using System
using System
using System
using System
using System
using System
using System
public partial class admin_ip : System
{
protected void Page_Load(object sender
{
Server
}
protected void Button
{
iplxb
odb
}
protected void LinkButton
{
for (int i =
{
if (iplxb
{
odb
iplxb
}
}
}
}
被需要限制IP的頁面調用頁的代碼
protected void Page_Load(object sender
{
string ip = Request
if (Convert
Response
}
}
From:http://tw.wingwit.com/Article/program/net/201311/14429.html