访问服务器端HTML控件 [英] Access to server side HTML controls
本文介绍了访问服务器端HTML控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<ul><li id="Accomodation" runat="server" visible="false">
<a href="../searchaccommodation.aspx?">Accomm</a></li></ul>
我有此代码.现在在服务器端,我想比较此id(Accommodation)值并想要id,即Accommodation.visible = true;
实际上,我不想手动检查b.innertext.,因为我必须先检查100种不同的类型...所以想要在服务器端访问b值并将该值与某些字符串数组(例如str [])进行比较.然后
i have this code.now on server side i want to compare this id(Accommodation) value and want id i.e.Accommodation.visible=true;
actually i dont want manually to check b.innertext.because i have to check then 100 of different types...so want that b value to be accessed on server side and compare that value with some string array say str[]. then
for(i=0;i<100;i++)
{
if(str[i]==b)
{
b.visible=true
}
}
b每次都会更改.
b will change every time
推荐答案
请重新编写该代码,这样才有意义.现在,Accommodation应该是一个可以在服务器端访问的变量.问题是什么?
Please rewrite this so it makes sense. Accomodation should now be a variable you can access on the server side. What is the issue ?
您可以使用InnerText属性访问此id的值.然后对其应用条件,将visible属性设置为true,即
在页面上
You can access the value of this id using InnerText property. then apply condition on it set visible property to true i.e
on page
<ul runat="server" id="a">
<li id="b" runat="server" visible="false">Test</li>
</ul>
在代码方面
on code side
if (b.InnerText == "Test")
{
b.Visible = true;
b.InnerText = "Text";
}
希望你有这个主意.
hope u got the idea.
这篇关于访问服务器端HTML控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文