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

求一个在Gridview模版列中可以使用的JS日历控件(精确到分钟)
很多JS日历控件拿来都不能使用,都是参数的问题估计是找不到控件的原因,求高手指点,如果没有,那么要怎么样才能使用JS获取模版列控件的ClientID, 通过
var temp = document.getElementById("<%=GridView.ClientID%>").getElementsByTagName("input");这种方法行不通。

------解决方案--------------------
例子
HTML code
<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  protected void Page_Load(object sender, EventArgs e)
  {
    if (!Page.IsPostBack)
    {
      GridView1.DataSource = new String[] { "A", "B" };
      GridView1.DataBind();
    }

  }

  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
      TextBox t = e.Row.FindControl("Text1") as TextBox;
      t.Attributes.Add("onclick", "alert('" + t.ClientID + " = ' + this.id)");
    }
  }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title></title>
</head>
<body>
  <form id="form1" runat="server">
  <asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound"
    AutoGenerateColumns="false">
    <Columns>
      <asp:TemplateField>
        <ItemTemplate>
          <asp:TextBox ID="Text1" runat="server"></asp:TextBox>
        </ItemTemplate>
      </asp:TemplateField>
    </Columns>
  </asp:GridView>
  </form>
</body>
</html>