c# - Make User Control hide/show -
i have main page: main.aspx , 2 user controls user1.ascx , user2.ascx. first, want user2.ascx invisible.i have hidden value in main page control. , if value of hidden value not null show user2.ascx. have typed code in prerender function on user2.ascx.
currently, try
in main.aspx
<usercontrol:user1 runat="server" id="user1control" visible = "false" />
by this, in user2, comes in pageload event not in onprerender.
i have code in onprerender
try this
protected void btntoggle_click(object sender, eventargs e) { string s = btntoggle.text; switch (s) { case "hide": btntoggle.text = "show"; break; case "show": btntoggle.text = "hide"; break; } ucdetails mycontrol = (ucdetails)page.loadcontrol("~/ucdetails.ascx"); usercontrolholder.controls.add(mycontrol); mycontrol.visible = !mycontrol.visible; }
the other option can create on javascript side. can wrap usercontrol in panel , hide , show through javascript function. hiding , showing through css.
<script type="text/javascript"> function hide() { document.getelementbyid("resultpanel2").style.display = 'none'; } </script>
Comments
Post a Comment