如何获取DataList里的控件
如何获取DataList里的控件比如说,我在里面放了一个DIV 我要通过里面的LinkButton1_Click 来实现隐藏和显示DIV 的功能,但不知道怎么获取DIV 这个控件的可视性! --------------------编程问答-------------------- 人呢,怎么没人顶啊 --------------------编程问答-------------------- js端行不.
div.style.display = none/block --------------------编程问答-------------------- 楼上能不能详细点! --------------------编程问答-------------------- document.all("divName").style.display = "none";
document.all("divName").style.display = "block";
--------------------编程问答-------------------- 前台
<div id="ff">
<asp:Button ID="Button3" runat="server" Text="del" UseSubmitBehavior="false"/>
</div>
后台
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.RegisterStartupScript("", "<script language=javascript defer>document.getElementById('ff').style.display = 'none';</script>")
End Sub --------------------编程问答-------------------- 或者后台
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "<script language=javascript defer>document.getElementById('ff').style.display = 'none';</script>")
End Sub
--------------------编程问答-------------------- 在_ItemDataBind()事件里写如下语句
(LinkButton)e.item.FindControl("LinkButton1")就能获取你想要的里面的LinkButton控件了 --------------------编程问答-------------------- protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
LinkButton link = (LinkButton)e.Item.FindControl("link1");
link.Attributes.Add("onclick", "javescript:DivShow()");
}
前台
<script language="javascript">
function DivShow()
{
alert("dddd");
var div=document.getElementById("div1");
if(div.style.display ="none")
{
div.style.display ="none"
}
else
{
div.style.display ="none"
}
}
</script>
datalist
<asp:DataList ID="DataList1" runat="server" BorderStyle="Dotted"
onitemdatabound="DataList1_ItemDataBound">
<ItemTemplate>
<table>
<tr <td><asp:LinkButton ID="link1" runat="server" Text="show"></asp:LinkButton></td>
<td> <div id="div1">
aaaaashow
</div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList> --------------------编程问答-------------------- 顶!! --------------------编程问答-------------------- http://blog.csdn.net/xianfajushi/archive/2008/11/30/3413317.aspx
补充:.NET技术 , ASP.NET