跳动问题 [英] quesion on runat
本文介绍了跳动问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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>
我在leftmenu.ascx页中有此代码.现在在leftmenu.ascx.cs页中,我要访问ID值.
但我不想像住宿,艺术等一样手动检查.
在cs文件中,我的代码就像
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
}
即我想遍历str的每个元素和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?
推荐答案
hi,
您需要将所有li元素都获取到页面?????
使用此代码
hi ,
u need to get all li element int the page ?????
use this code
<br />
<br />
<pre lang="cs"><br />
<br />
public Dictionary<string ,string > _dic { get; set; }<br />
public Dictionary<string, string> dic<br />
{<br />
get<br />
{<br />
if (_dic == null)<br />
{<br />
_dic = new Dictionary<string, string>();<br />
}<br />
return _dic;<br />
}<br />
set<br />
{<br />
_dic = value;<br />
}<br />
}<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
Get(this.Controls);<br />
foreach (KeyValuePair<string,string > val in dic )<br />
{<br />
Response.Write(val.Value+"<br/>");<br />
if (1==1) //here your condition <br />
{<br />
FindControl(val.Value).Visible = true;<br />
} <br />
<br />
}<br />
}<br />
protected void Get(ControlCollection conColl)<br />
{ <br />
foreach (Control con in conColl)<br />
{<br />
if (con.GetType() == typeof(System.Web.UI.HtmlControls.HtmlGenericControl) && con.Controls[0].GetType() == typeof(LiteralControl))<br />
{<br />
dic[con.ID] = con.ID;<br />
}<br />
else<br />
{<br />
Get(con.Controls);<br />
}<br />
}<br />
}</pre><br />
<br />
<br />
如果您无法访问该元素为C#cs代码,则应
定义控件的name属性,然后您将在cs Code中访问它.
问候
Abraheem Abulubbad
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
这篇关于跳动问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文