【发布时间】:2017-02-04 00:06:43
【问题描述】:
我有一个包含 iframe、ASP 标签和按钮的父页面。 当用户点击父按钮时,它会在 iframe 中显示一些表格结果。 现在我想根据 iframe 的结果显示具有不同文本和颜色的父标签。 所以我正在尝试在 iframe 后面的代码(C#)中从父级检索标签并为其分配一个 CssClass。但无论我做什么,当试图从父级找到控件时,它总是返回一个空引用。 有人可以帮忙吗?
父页面代码:
<div class="search-row">
<div class="search">
<button id="btnSearch" type="submit" class="button button-block">Search</button>
</div>
<div class="search" style="padding-top: 20px;">
<asp:Label ID="wrapperResponse" CssClass="resp" runat="server">TEST</asp:Label>
</div>
</div>
<div id="iframeDiv">
<iframe name="my_frame" width="100%" height="350px" src="Results.aspx" scrolling="no" frameborder="0"></iframe>
</div>`
Results.aspx 将显示一个表格,其中包含一些动态生成的 html。 现在假设结果表有一行,我希望 Label WrapperReponse 为绿色并显示“1 行”,但如果为 2 行,那么我希望它为红色并显示“2 行”
在我的 Results.aspx.cs 中我尝试了
String test= String.Format("{0}", Request.Form["wrapperResponse"]);
Label statusResponse = (Label)this.FindControl("wrapperResponse");
Label statusResponse2 = (Label)Parent.FindControl("wrapperResponse");
欢迎任何想法! 谢谢
【问题讨论】:
标签: c# iframe findcontrol