C#怎么实现用JS控制Repeater里的控件显示与否?
我想实现一个跟QQ空间一样,点下回复就把事先隐藏的输入框和两个按钮显示出来!请哪位大虾帮忙搞定下谢谢~...
我想实现一个跟QQ空间一样,点下回复就把事先隐藏的输入框和两个按钮显示出来!请哪位大虾帮忙搞定下谢谢~
展开
3个回答
展开全部
给repeater加一个style="display:none;"
然后再给这个控件加一个onclick事件
var repeater = document.getElementById("控件id");
if(repeater.style.display=='none'){
repeater.style.display=='block'
}
else if(repeater.style.display=='block'){
repeater.style.display=='none'
}
然后再给这个控件加一个onclick事件
var repeater = document.getElementById("控件id");
if(repeater.style.display=='none'){
repeater.style.display=='block'
}
else if(repeater.style.display=='block'){
repeater.style.display=='none'
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<script>
function showEdit() {
var srcElement = event.srcElement;
var div = srcElement.parentNode.getElementsByTagName('div')[0];
div.style.display = "block";
}
</script>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div><%#Eval("title") %> <a href="#" onclick="showEdit()">评论</a>
<div id='talk' style='display:none;'>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1"
runat="server" Text="Button" /></div></div>
</ItemTemplate>
</asp:Repeater>
或者用这种方式
<script>
function showEdit(index) {
var talkDiv = document.getElementById("Repeater1_ctl" + converttostring(index) + "_talk");
talkDiv.style.display = "block";
}
function converttostring(obj) {
var str = obj.toString();
var objLength = str.length;
if (objLength < 2) {
str = "0" + str;
}
return str;
}
</script>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div><%#Eval("title") %> <a href="#" onclick="showEdit(<%#Container.ItemIndex %>)">评论</a>
<div id='talk' style='display:none;' runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1"
runat="server" Text="Button" /></div></div>
</ItemTemplate>
</asp:Repeater>
function showEdit() {
var srcElement = event.srcElement;
var div = srcElement.parentNode.getElementsByTagName('div')[0];
div.style.display = "block";
}
</script>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div><%#Eval("title") %> <a href="#" onclick="showEdit()">评论</a>
<div id='talk' style='display:none;'>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1"
runat="server" Text="Button" /></div></div>
</ItemTemplate>
</asp:Repeater>
或者用这种方式
<script>
function showEdit(index) {
var talkDiv = document.getElementById("Repeater1_ctl" + converttostring(index) + "_talk");
talkDiv.style.display = "block";
}
function converttostring(obj) {
var str = obj.toString();
var objLength = str.length;
if (objLength < 2) {
str = "0" + str;
}
return str;
}
</script>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div><%#Eval("title") %> <a href="#" onclick="showEdit(<%#Container.ItemIndex %>)">评论</a>
<div id='talk' style='display:none;' runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1"
runat="server" Text="Button" /></div></div>
</ItemTemplate>
</asp:Repeater>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询