日期:2014-05-17  浏览次数:21028 次

我写了一个用户控件,页面调用多次,但是总是只能正常显示第一个,帮我找找一下错误.
WebForm1.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication7.WebForm1" %>
<%@ Register src="re_Seckill.ascx" tagname="re_Seckill" tagprefix="uc1" %>
<!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>
  <div><uc1:re_Seckill ID="re_Seckill1" runat="server" StartSeckill="2012-09-29 23:05:12" EndSeckill="2012-09-29 23:12:32" /></div>
  <div><uc1:re_Seckill ID="re_Seckill2" runat="server" StartSeckill="2012-09-29 23:05:12" EndSeckill="2012-09-29 23:12:32" /></div>
  </div>
  </form>
</body>
</html>


re_Seckill.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="re_Seckill.ascx.cs" Inherits="WebApplication7.re_Seckill" %>
  <style type="text/css">
  .style1
  {
  color:#FF0000;
  font-weight:bold;
  padding-left:7px;
  padding-right:7px;
  }
</style>
<script language="JavaScript" type="text/javascript">

  function showTimeLimit(str, end, i) {
  var now = new Date(str);
  var future = new Date();
  future -= 1000;

  if (now - future > 0) {
  var days = (now - future) / 1000 / 60 / 60 / 24;
  var dayNum = Math.floor(days);
  var hours = (now - future) / 1000 / 60 / 60 - (24 * dayNum);
  var houNum = Math.floor(hours);
  if (houNum < 10) {
  houNum = "0" + houNum;
  }
  var minutes = (now - future) / 1000 / 60 - (24 * 60 * dayNum) - (60 * houNum);
  var minNum = Math.floor(minutes);
  if (minNum < 10) {
  minNum = "0" + minNum;
  }
  var seconds = (now - future) / 1000 - (24 * 60 * 60 * dayNum) - (60 * 60 * houNum) - (60 * minNum);
  var secNum = Math.floor(seconds);
  if (secNum < 10) {
  secNum = "0" + secNum;
  }
  document.getElementsByName('TimeLimit1')[i].innerHTML = "距秒杀开始还有:<span class=\"style1\">" + dayNum + "</span>天<span class=\"style1\">" + houNum + "</span>小时<span class=\"style1\">" + minNum + "</span>分<span class=\"style1\">" + secNum + "</span>秒";
  }

  else {
  // setInterval('showTimeLimit(\"2012/09/29 09:11:50\",\"0\")', 1000);

  var now = new Date(end);
  var future = new Date();
  future -= 1000;

  if (now - future > 0) {
  var days = (now - future) / 1000 / 60 / 60 / 24;
  var d