62,046
社区成员
发帖
与我相关
我的任务
分享
前台绑定:
<ItemTemplate>
<% if (xmlUrlList.Length != 0)
{
for (int i = 0; i < xmlUrlList.Length; i++)
{%>
<tr>
<td>
<asp:CheckBox ID="CheckBox1" runat="server" Checked="true" Text='<%# Eval("IDurl")%>' />
</td>
<td style="font-size: 13px; text-align: left;">
<%# Eval("testurl")%>
</td>
<td>
<%= RepeatText[i]%>
</td>
<td>
<%= StartTime[i]%>
</td>
<td>
<%= ENDTime[i]%>
</td>
</tr>
<%}
}%>
</ItemTemplate>
后台定义数组变量:
protected string[] RepeatText;
protected string[] StartTime;
protected string[] ENDTime;
protected string[] xmlUrlList;
for (int i = 0; i < xmlUrlList.Length; i++)
{
url = xmlUrlList[i] + "?request=" + PathText;
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
Stream mystream = response.GetResponseStream();
StreamReader mystreamReader = new StreamReader(mystream);
string strtxt = mystreamReader.ReadToEnd();
RepeatText[i] = fcsion.DecoderBase64(strtxt);
StartTime[i] = DateTime.Now.ToString();
ENDTime[i] = response.LastModified.ToString();
}
这样绑定有问题吗?
页面绑定:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebTest.aspx.cs" Inherits="WebTest" %>
<!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>测试工具BS.beta1.0版</title>
<style type="text/css">
.myTable, .myTable td
{
border: 1px solid #cccccc;
border-collapse: collapse;
width: 740px;
margin: 0 auto;
}
.myTable1
{
width: 800px;
margin: 0 auto;
}
</style>
<script type="text/javascript" src="JS/jquery-1.4.1-vsdoc.js"></script>
<script type="text/javascript">
$(function () {
$("#btnAddURL").click(function () {
var URLText = $("#txtURLText").val();
if (URLText.length == 0) {
$("#DIVBTNADDURL").html("<font color='red'> * URL不能为空!</font>");
return false;
}
else if (URLText == "null") {
$("#DIVBTNADDURL").html("<font color='red'> * URL输入不正确!</font>");
return false;
}
});
$("#btnStartTest").click(function () {
var FileText = $("#FileUpload1").val();
if (FileText.length == 0) {
$("#DivFile").html("<font color='red'> * 请选择测试的文件!</font>");
return false;
}
});
$("#FileUpload1").mouseover(function () {
$("#DivFile").html("<font color='red'> * 添加文件必须是.txt!</font>");
});
$("#FileUpload1").mouseout(function () {
$("#DivFile").html("<font color='red'> </font>");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="font-size: 12px; text-align: center;">
<div id="DIVTOP">
<table class="myTable1">
<tr>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" Width="220px" />
</td>
<td>
<asp:Button ID="btnStartTest" runat="server" Text="开始测试" OnClick="btnStartTest_Click" />
</td>
<td style="width: 418px;">
<div id="DivFile">
</div>
</td>
</tr>
</table>
</div>
<div id="DIVCENTER" style="text-align: center; margin-top: 20px; margin-bottom: 20px;">
<table class="myTable">
<tr>
<td>
选择
</td>
<td>
URL
</td>
<td>
返回结果
</td>
<td>
发送时间
</td>
<td>
返回时间
</td>
</tr>
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="CheckBox1" runat="server" Checked="true" Text='<%# Eval("IDurl")%>' />
</td>
<td style="font-size: 13px; text-align: left;">
<%# Eval("testurl")%>
</td>
<%int len = xmlUrlList == null ? 0 : xmlUrlList.Length; %>
<% for (int i = 0 ; i < len ==true?true:false; i++)
{%>
<td>
<%= RepeatText[i] %>
</td>
<td>
<%= StartTime[i] %>
</td>
<td>
<%= ENDTime[i] %>
</td>
<%}%>
</tr>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblEmpty" Text="列表暂无数据!" runat="server" Visible='<%#bool.Parse((Repeater1.Items.Count==0).ToString())%>'>
</asp:Label>
</FooterTemplate>
</asp:Repeater>
</table>
</div>
<div id="DIVADD" style="">
<table class="myTable1">
<tr>
<td>
<asp:TextBox ID="txtURLText" runat="server" Width="220px"></asp:TextBox>
</td>
<td>
<asp:Button ID="btnAddURL" runat="server" Text="添加地址" OnClick="btnAddURL_Click" />
</td>
<td style="width: 418px;">
<div id="DIVBTNADDURL">
</div>
</td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>
for (int i = 0; i < xmlUrlList.Length; i++)
{
RepeatText = new Hashtable();
StartTime = new Hashtable();
ENDTime = new Hashtable();
url = xmlUrlList[i] + "?request=" + PathText;
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);//创建一个HttpWebRequest对象
HttpWebResponse response = (HttpWebResponse)req.GetResponse();//根据创建的HttpWebRequest来创建HttpWebResponse对象
Stream mystream = response.GetResponseStream();//取得返回后的stream
StreamReader mystreamReader = new StreamReader(mystream);//把Stream转换为StreamReader
string strtxt = mystreamReader.ReadToEnd();//读取出返回的内容
RepeatText.Add(i, fcsion.DecoderBase64(strtxt)); //解密返回的内容
StartTime.Add(i, DateTime.Now.ToString());
ENDTime.Add(i,response.LastModified.ToString());
}