c#获取前台html的问题
程序代码:for (int i = 1; i < 5; i++)
{
if (imgdt.Rows[i-1] != null)
{
HtmlImage bigimg = this.FindControl("bidimg" + i.ToString()) as HtmlImage;
HtmlImage sllimg = this.FindControl("smallimg" + i.ToString()) as HtmlImage;
if (bigimg != null && sllimg != null)
{
bigimg.Src = imgdt.Rows[i - 1]["BigImg"].ToString();
sllimg.Src = imgdt.Rows[i - 1]["SmallImg"].ToString();
}
}
}
前台html(samllimg,bigimg一样):
<li onmouseover="setTab(2,0)" class="now"><img id="smallimg1" runat="server" src="../images/ProInforPicS_03.jpg" /></li>
<li onmouseover="setTab(2,1)"><img id="smallimg2" runat="server" src="../images/ProInforPicS_05.jpg" /></li>
<li onmouseover="setTab(2,2)"><img id="smallimg3" runat="server" src="../images/ProInforPicS_07.jpg" /></li>
<li onmouseover="setTab(2,3)"><img id="smallimg4" runat="server" src="../images/ProInforPicS_09.jpg" /></li>
问题:
this.FindControl("bidimg" + i.ToString()) as HtmlImage;
取不到html,为空~~~~
希望得到解决,谢谢。
ps:我需要用循环,所以请别告诉我直接写 id就可以,我知道,但是那样不能实现我的功能,谢谢。