Click here to Skip to main content
16,019,764 members
Please Sign up or sign in to vote.
2.67/5 (3 votes)
See more:
XML
<ul>
                    <li id="Accommodation" runat="server" visible="false"><a href="../Elements/frmSearchAccommodation.aspx?submenuheader=1">Accommodation</a></li>
                    <li id="Arts" runat="server" visible="false"><a href="../Elements/frmSearchProp.aspx?submenuheader=1">Arts And Props</a></li>
                    <li id="Costume" runat="server" visible="false"><a href="../Elements/frmSearchCostume.aspx?submenuheader=1">Costume</a></li>
                    <li id="Crew" runat="server" visible="false"><a href="../Elements/frmSearchCrew.aspx?submenuheader=1">Crew</a></li>
                    <li id="Catering" runat="server" visible="false"><a href="../Elements/frmSearchCatering.aspx?submenuheader=1">Catering</a></li>
                    <li id="Equipment" runat="server" visible="false"><a href="../Elements/frmSearchEquipment.aspx?submenuheader=1">Equipment</a></li>
                    <li id="Film" runat="server" visible="false"><a href="../Elements/frmSearchFilmTapeStock.aspx?submenuheader=1">Film And Tape Stocks</a></li>
                    <li id="Location" runat="server" visible="false"><a href="../Elements/frmSearchLocation.aspx?submenuheader=1">Location</a></li>
                    <li id="Picture" runat="server" visible="false"><a href="../Elements/frmSearchPictureVehicle.aspx?submenuheader=1">Picture Vehicles</a></li>
                    <li id="Production" runat="server" visible="false"><a href="../Elements/frmSearchProductionSupplies.aspx?submenuheader=1">Production Supplies</a></li>
                    <li id="Post" runat="server" visible="false"><a href="../Elements/frmSearchPostProductionHouse.aspx?submenuheader=1">Post Production Houses</a></li>
                    <li id="Rigging" runat="server" visible="false"><a href="../Elements/frmSearchRigging.aspx?submenuheader=1">Rigging</a></li>
                    <li id="Stunt" runat="server" visible="false"><a href="../Elements/frmSearchStunt.aspx?submenuheader=1">Stunt</a></li>
                    <li id="Studio" runat="server" visible="false"><a href="../Elements/frmSearchStudio.aspx?submenuheader=1">Studio</a></li>
                    <li id="SFX" runat="server" visible="false"><a href="../Elements/frmSearchSFX.aspx?submenuheader=1">SFX</a></li>
                    <li id="Talents" runat="server" visible="false"><a href="../Elements/frmSearchTalent.aspx?submenuheader=1">Talents</a></li>
                    <li id="Transport" runat="server" visible="false"><a href="../Elements/frmSearchTransport.aspx?submenuheader=1">Transport</a></li>
                    <li id="Venue" runat="server" visible="false"><a href="../Elements/frmSearchVenue.aspx?submenuheader=1">Venue</a></li>
                    <li id="Other" runat="server" visible="false"><a href="../PageUnderConstruction.aspx?submenuheader=1">Other</a></li>
 </ul>


I have this code in leftmenu.ascx page..now on leftmenu.ascx.cs page i want to access id values.
but i dont want to check manually like Accommodation,Arts etc..
In cs file my code is like
string str[];
//this array contains some values say 10 strings
for(i=0;i<100;i++)
{
    if(str[i]==id
    id.visible=true
}

i.e.i want to travel for each element of str and each value of id.if they match then id.visible=true

How to do?
Posted
Updated 4-May-10 1:56am
v2
Comments
Christian Graus 4-May-10 17:09pm    
What is wrong with people like you ? You asked the same question twice, and reverted to the semi meaningless title you used, instead of using the more sensible title I suggested. If you're too dumb to understand the answer, asking it again won't help, and is plain rude. You should have edited your original post to add detail and ask for clarification.

1 solution

hi ,

u need to get all li element int the page ?????
use this code


C#
public Dictionary<string ,string > _dic { get; set; }
public Dictionary<string, string> dic
{
    get
    {
        if (_dic == null)
        {
            _dic = new Dictionary<string, string>();
        }
        return _dic;
    }
    set
    {
        _dic = value;
    }
}
 
protected void Page_Load(object sender, EventArgs e)
{
  Get(this.Controls);
  foreach (KeyValuePair<string,string > val in dic )
  {
      Response.Write(val.Value+"<br/>");
 if (1==1) //here your condition 
    {
        FindControl(val.Value).Visible = true;
    } 

  }
}
protected void  Get(ControlCollection conColl)
{ 
    foreach (Control con in conColl)
    {
            if (con.GetType() == typeof(System.Web.UI.HtmlControls.HtmlGenericControl) && con.Controls[0].GetType() == typeof(LiteralControl))
            {
             dic[con.ID]  = con.ID;
            }
            else
            {
                Get(con.Controls);
            }
    }
}

if u cant access the the element is C# cs code u should
define the name property for the control then u will access it in cs Code .

regards
Abraheem Abulubbad
 
Share this answer
 
v6

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900