1.配合 Menu 操作 iframe 內容

Asp.Net menu:  重點在 target 目標為 iframe 的 name

<asp:Menu ID="Menu1" runat="server">
        <Items>
            <asp:MenuItem NavigateUrl="target_url" Target="iframe1" Text="target" 
                Value="target"></asp:MenuItem>
        </Items>
</asp:Menu>

 

Asp.Net iframe: 一定要輸入 name 值

<IFRAME id="iframe1" name="iframe1" src="default.html" scrolling="auto" runat=server 
               height="500" width="700">
/IFRAME>

 

2.動態變更內容

同上 , 拉一個 iframe 進aspx 頁面裡

C#  Page_Load 加入以下指令

protected void Page_Load(object sender, EventArgs e)
   {
       HtmlControl iframe1 = (HtmlControl)this.FindControl("iframe1");
   }

在需要動態變更頁面的地方添加:

iframe1.Attributes["src"] = http://yourserver;

動態變更 iframe 尺寸

iframe1.Attributes["width"] = "500px"; 
iframe1.Attributes["height"] = "500px"; 
arrow
arrow
    文章標籤
    asp.net iframe
    全站熱搜

    jason0324 發表在 痞客邦 留言(0) 人氣()