471,582 Members | 1,429 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,582 software developers and data experts.

Show and Hide

Hello,

I created an Asp:Repeater where I have an Asp:Panel and an Asp:Label.
In each record of the repeater I want to have a small button which
hides or shows the panel in that record. If possible with no postback.

And it would be great to have a button like "Show" which would change
to "Hide".
Well, but this is not so important.

Could somebody, please, help me out with this? I have no idea of how to
create this.

Thanks,
Miguel

Oct 19 '06 #1
1 1732
hi

You can use javascript to hide/show the panel inside the repeater.

Create Javascritp function to hide or show panel

function show_hide(pnl, btn)
{
document.getElementById(pnl).style.display =
document.getElementById(pnl).style.display == "none" ? "block" :
"none";

if (document.getElementById(pnl).style.display=="bloc k")
document.getElementById(pnl).caption="Hide";
else
document.getElementById(pnl).caption="Show";
}

now you can call these function on click event of button, to do that
you have bind to fucntion to button control on ItemCreated Event of
Reapeate. following is the code for that.

Private Sub Repeater1_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
Repeater1.ItemCreated

Dim rtpItem As ListItemType
Dim pnl As HtmlGenericControl
Dim btn As Button
rtpItem = ListItemType.Item
If rtpItem = ListItemType.AlternatingItem Or rtpItem =
ListItemType.Item Then
pnl = CType(e.Item.FindControl("pnl"), HtmlGenericControl)
btn = CType(e.Item.FindControl("btn"), Button)
btn.Attributes.Add("onclick", "show_hide('" & pnl.ClientID
& "','" & btn.ClientID & "');")
End If

End Sub

Note to get the panel control using e.Item.FindControl("pnl") you must
have to make the html panel a server control it means you have to write
runat="server" in html tag of panel control. otherwise you will get
error like control with name pnl not found.

shapper wrote:
Hello,

I created an Asp:Repeater where I have an Asp:Panel and an Asp:Label.
In each record of the repeater I want to have a small button which
hides or shows the panel in that record. If possible with no postback.

And it would be great to have a button like "Show" which would change
to "Hide".
Well, but this is not so important.

Could somebody, please, help me out with this? I have no idea of how to
create this.

Thanks,
Miguel
Oct 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ajai Kumar .R | last post: by
10 posts views Thread by oLE | last post: by
3 posts views Thread by alex | last post: by
4 posts views Thread by bridgemanusa | last post: by
7 posts views Thread by FP | last post: by
5 posts views Thread by ali | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.