c# - Make a <li> invisible in asp.net -


is there way make li id litest , lilogout invisible?

i tried this:

litest.visible = false  

but error:

error 3, name 'litest' not exist in current context

 <asp:loginview runat="server" viewstatemode="disabled">      <anonymoustemplate>          <ul class="nav navbar-nav navbar-right">              <li><a runat="server" href="~/account/register">register</a></li>              <li><a runat="server" href="~/account/login">log in</a></li>              <li><a  id="litest" runat="server" >test</a></li>              <li><a id="lilogout" runat="server"  >logout</a></li>          </ul>      </anonymoustemplate> 

reference: how to: access server controls id

when control not inside naming container, can reference using control's id. when control inside naming container, must call method searches naming container control's id. control might inside naming container not have direct access to.

so, need write function search design time id @ runtime, so:

private control findcontrolrecursive(control rootcontrol, string controlid) {     if (rootcontrol.id == controlid) return rootcontrol;      foreach (control controltosearch in rootcontrol.controls)     {         control controltoreturn =              findcontrolrecursive(controltosearch, controlid);         if (controltoreturn != null) return controltoreturn;     }     return null; } 

then call function reference control need:

var ctrl = findcontrolrecursive(this, "litest"); if (ctrl !=null) {    ctrl.visible = false; } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -