日期:2014-05-18  浏览次数:20556 次

JS如何获取服务器控件值
就像CSDN上那样,当鼠标移到用户头像上时,会出现用户的详细信息.现在问题里如何用JS获取当前鼠标指向的用户ID.

------解决方案--------------------
如果在一般的代码中书写:
foreach (GridViewRow row in this.gvListButton.Rows)
{
iNum = Convert.ToInt32(((Label)row.Cells[5].FindControl("Label1")).Text); ---数字类型
sName = ((TextBox)row.Cells[4].FindControl("TextBox9")).Text; ---字符类型(其他类型可用相对应的类型转换)
}



如果在RowDataBound事件或其他事件中
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TextBox txt = (TextBox)e.Row.FindControl("TextBox9");
}
}


其他的你就自己研究下吧!
------解决方案--------------------
HTML code
<a onmouseover="getID(this.id);" id="<%#Eval("ID") %>">取ID</a>