得不到的,asp.net里面隐藏的东西,在客户端不会被翻译成html的
所以隐藏的内容,只能在服务器上得到,客户端无法得到,服务器是通过用ViewState来保存所有控件的状态的。
你可以在服务端程序里把要得到的东西,放到一个隐藏域(hidden)里,然后在客户端用js取得
这是一个思路

解决方案 »

  1.   

    得不到,只能先把它放到一个隐藏区中,如<div style="display:none"><asp:textbox id=aa runat=server></asp:textbox></div>这样你在客户端才能通过JS得到它的值
      

  2.   

    to 楼上的两位大哥,能否给个完整的例子,就是在选中了那个checkbox后,在服务器端得到隐藏的两列的值,在那个事件中写,怎样传给那个隐藏的textbox,谢谢了!
      

  3.   

    怎样把DataGrid中的某列放在隐藏域中呀?????????
      

  4.   

    直接是得不到的。只能通过中介来得到。比如上面说的做一个隐藏的层。或则做一个Width为0的框架。或着用隐藏的Input。方法很多,根据实际的情况选用。
      

  5.   

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace JBInfoManage._2052.ASPX.Analy
    {
    /// <summary>
    /// SignDts 的摘要说明。
    /// </summary>
    public class SignDts : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Button Button1;
    protected System.Web.UI.WebControls.DataGrid grd1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    if(this.Session["Admin"].ToString()=="True")
    {
    }
    else
    {
    JBInfoBase.Security pS=new JBInfoBase.Security();
    if(!pS.GetFunction(int.Parse(this.Session["EmpID"].ToString()),"Stu0001002"))//有没有删除的权限
    {
    this.Response.Redirect("../common/noroot.aspx");
    }
    }
    if(!this.IsPostBack)
    {
    FillDataGrid(0);
    }
    }
    private void FillDataGrid(int page)
    {
    JBInfoBase.SingMems pSM=new JBInfoBase.SingMems();
    DataTable pDT=pSM.SignDts("");
    this.grd1.DataSource=pDT;
    this.grd1.CurrentPageIndex=page;
    this.grd1.DataBind();

    foreach(DataGridItem item in grd1.Items )
    {
    for(int i=1;i<grd1.Columns.Count;i++)
    { item.Cells[i].Attributes.Add("onclick","javascript:self.location.href='Sign.aspx?BillID="+ ((CheckBox)item.Cells[0].Controls[1]).ToolTip.ToString() +"'");
    item.Cells[i].Attributes.Add("Style","cursor:hand;");
    }
    item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#b7c4e2'");
    item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");

    }
    }
    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.grd1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.grd1_PageIndexChanged);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void grd1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
    {
    this.FillDataGrid(e.NewPageIndex);
    }
    }
    }