c# - 如何在 c# 中单击按钮时显示 iframe,并在显示另一个网格或 iframe 时使其不可见?

标签 c# html asp.net iframe

我正在 visual studio 10 中使用 asp.net/c# 构建数据库驱动的 Web 应用程序 (实际上这是我的第一个,所以我希望这个问题不是愚蠢之类的)我应该在后面的代码中的 Button_Click 事件中编写什么代码,以便在单击按钮时显示 iframe 并在加载另一个对象时隐藏(对于例如 Gridview)?我在任何其他答案中都找不到任何匹配的脚本。这是 iframe 的代码:

<asp:Panel>
  
  
//...some code about gridviews and dropdownlists....//
  

<div id ="Frame" class="iframe">
  
<iframe name="iframe" id="iframe1" src="AddProject.aspx" class="iframe>
                                                                
</iframe>
                                                                
</div> 
                                                                
</asp:Panel>
                                                                           
<asp:Button ID="Button1" runat="server" Text="Add Project" Width="127px"/>

最佳答案

您需要在您的 div 中设置 runat 属性以使其工作

<div id="Frame" runat="server">

你可以隐藏第i帧所在的div

在您的按钮点击事件中,您放置:
Frame.Visible = true;//显示 div

Frame.Visible = false;//隐藏 div

这也适用于 iframe 本身

这你也可以在像 gridview .ect 这样的控件上使用

 GridView1.Visible = true;
 GridView1.Visible = false;

关于c# - 如何在 c# 中单击按钮时显示 iframe,并在显示另一个网格或 iframe 时使其不可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35445549/

相关文章:

c# - 将反序列化的动态 Json 转换为强类型类

c# - 动态 linq 和运算符重载

c# - Jquery 自动完成 .NET WebMethod

java - 试图在 asp.net 和 jsp 之间做出决定

c# - 在生产环境中运行的 ASP.NET 应用程序崩溃了

c# - 放置与桌面重叠的图像

javascript - 等待网站完成加载所有 javascript

html - slider 中的内容不适合移动设备

jquery - 如何向图像链接添加简单的反馈?

c# - 如何生成具有组格式的 TreeView ? (表示起始词的字母)