2010-04-12 2 views
0

대용량 정적 HTML 및 asp.net 코드를 포함하는 것에 대한 간단한 질문입니다. #include를 지금 사용하고 있으며 iframe이 처리의 더 나은 방법인지 궁금합니다. 내가하고 싶은 일을하거나 더 좋은 방법이 있습니다. 여기 내가이 처리하고있어 현재의 방법은 #include 파일 대 iframe 또는 더 나은 방법이 있습니다

<div class="CommonTabBar"> 

    <script language="javascript"> 
     function tabOver(e) { 
      if (e.className != 'CommonSimpleTabStripSelectedTab') 
       e.className = 'CommonSimpleTabStripTabHover'; 
     } 
     function tabOut(e) { 
      if (e.className != 'CommonSimpleTabStripSelectedTab') 
       e.className = 'CommonSimpleTabStripTab'; 
     } 
     function tabOverSub(e) { 
      if (e.className != 'CommonSimpleTabStripSelectedTabSub') 
       e.className = 'CommonSimpleTabStripTabHoverSub'; 
     } 
     function tabOutSub(e) { 
      if (e.className != 'CommonSimpleTabStripSelectedTabSub') 
       e.className = 'CommonSimpleTabStripTabSub'; 
     } 
    </script> 

    <table border="0" cellpadding="0" cellspacing="0"> 
     <tbody> 
      <tr valign="middle"> 
       <td class="CommonSimpleTabStripTab" style="padding: 0px"> 
        &nbsp; 
       </td> 
       <td class="CommonSimpleTabStripTab" onmouseover="tabOver(this);" onmouseout="tabOut(this);" 
        onclick="window.location = 'http://www.cigar.com/index.asp'"> 
        <a style="float: right; display: block; height: 30px; line-height: 30px; padding-left: 12px; 
         padding-right: 12px; vertical-align: middle;" href="http://www.cigar.com/index.asp"> 
         Home</a> 
       </td> 
       <td class="CommonSimpleTabStripTab" onmouseover="tabOver(this); document.getElementById('ComDropDown2').style.display = 'inline';" 
        onmouseout="tabOut(this); document.getElementById('ComDropDown2').style.display = 'none';"> 
        <a style="float: right; display: block; height: 30px; line-height: 30px; padding-left: 12px; 
         padding-right: 12px; vertical-align: middle;" href="http://www.cigar.com/cigars/index.asp"> 
         Cigars</a> 
        <div id="ComDropDown2" style="border: 1px solid rgb(71, 42, 24); margin: 28px 0px 0px; 
         display: none; background-color: rgb(235, 230, 208); color: rgb(71, 42, 24); 
         position: absolute; float: left; z-index: 200;" onmouseover="document.getElementById('ComDropDown2').style.display = 'inline';" 
         onmouseout="document.getElementById('ComDropDown2').style.display = 'none';"> 
         <ul style="margin: 0px; padding: 0px; width: 100px;"> 
          <li class="CommonSimpleTabStripTabSub" style="margin: 0px; padding: 3px; text-align: left; 
           list-style: none outside none;" onmouseover="tabOverSub(this); " onmouseout="tabOutSub(this); " 
           onclick="window.location = 'http://www.cigar.com/cigars/index.asp'"><a href="http://www.cigar.com/cigars/index.asp" 
            style="line-height: 25px; color: rgb(71, 42, 24);" id="BrandsLink">Brands </a> 
          </li> 
          <li class="CommonSimpleTabStripTabSub" style="margin: 0px; padding: 3px; text-align: left; 
           list-style: none outside none;" onmouseover="tabOverSub(this); " onmouseout="tabOutSub(this); " 
           onclick="window.location = 'http://www.cigar.com/cigars/privatelabel.asp?brand=419'"> 
           <a href="http://www.cigar.com/cigars/privatelabel.asp?brand=419" style="line-height: 25px; 
            color: rgb(71, 42, 24);" id="SamplersLink">Aging Room </a></li> 
          <li class="CommonSimpleTabStripTabSub" style="margin: 0px; padding: 3px; text-align: left; 
           list-style: none outside none;" onmouseover="tabOverSub(this); " onmouseout="tabOutSub(this); " 
           onclick="window.location = 'http://www.cigar.com/cigars/samplers.asp'"><a href="http://www.cigar.com/cigars/samplers.asp" 
            style="line-height: 25px; color: rgb(71, 42, 24);" id="SamplersLink">Samplers 
           </a></li> 
          <li class="CommonSimpleTabStripTabSub" style="margin: 0px; padding: 3px; text-align: left; 
           list-style: none outside none;" onmouseover="tabOverSub(this); " onmouseout="tabOutSub(this); " 
           onclick="window.location = 'http://www.cigar.com/cigars/suggestions.asp'"><a href="http://www.cigar.com/cigars/suggestions.asp" 
            style="line-height: 25px; color: rgb(71, 42, 24);" id="SuggestionsLink">Suggestions 
           </a></li> 
          <li class="CommonSimpleTabStripTabSub" style="margin: 0px; padding: 3px; text-align: left; 
           list-style: none outside none;" onmouseover="tabOverSub(this); " onmouseout="tabOutSub(this); " 
           onclick="window.location = 'http://www.cigar.com/DailyDeal/ccCigarDeals.asp'"><a 
            href="http://www.cigar.com/DailyDeal/ccCigarDeals.asp" style="line-height: 25px; 
            color: rgb(71, 42, 24);" id="SuggestionsLink">Suggestions </a></li> 
         </ul> 
        </div> 

내가했던 예를 Redid commonTabBar.html

<table cellpadding="0" cellspacing="0" width="790px"> 
    <tr> 
     <td align="left"> 
      <img src="images/smokechair.jpg" alt="Cigar.com" /><img src="images/cigarcomTitle.gif" 
       alt="Cigar.com" /> 
     </td> 
     <td align="right"> 
      <table width="310px" height="73px" cellpadding="0" cellspacing="0" style="padding-right: 6px"> 
       <tr> 
        <td width="109px" class="welcome" align="left"> 
        Welcome to Cigar.com 
        </td> 
        <td width="195px" class="welcome" align="left"> 
         <div runat="server" id="divUser"> 
          <table cellpadding="0" cellspacing="0" align="right"> 
           <tr> 
            <td width="126px" align="left"> 
             <asp:Label ID="lblUserName" CssClass="welcome" runat="server"></asp:Label></td> 
            <td width="65px" align="left"> 
             <a href="http://www.cigar.com/cs/languages/en-US/docs/faq.aspx">Help</a></td> 
           </tr> 
          </table> 
         </div> 
         <div runat="server" id="divGuest"> 
          <a href="OutsideLogin.aspx">Sign In</a> | <a href="OutsideLogin.aspx">Join</a> | 
          <a href="http://www.cigar.com/cs/languages/en-US/docs/faq.aspx">Help</a> 
         </div> 
        </td> 
       </tr> 
       <tr> 
        <td colspan="2"> 
         <table cellpadding="0" cellspacing="0" > 
          <tr> 
           <td width="234px" align="right"> 
            <asp:DropDownList ID="ddlCriteria" runat="server"> 
             <asp:ListItem>Posts</asp:ListItem> 

             <asp:ListItem>Posted By</asp:ListItem> 
            </asp:DropDownList> 
           <asp:TextBox Width="120px" ID="txtSearch" runat="server"></asp:TextBox> 
           </td> 
           <td width="70px" align="center"> 
              <asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="sbutton" OnClick="btnSearch_Click" /> 

           </td> 
          </tr> 
         </table> 
        </td> 
       </tr> 
      </table> 
     </td> 
    </tr> 
    <tr> 
     <td colspan="2"> 
     <!--#include file="commonTabBar.html" --> 

     </td> 
    </tr> 
</table> 

default.aspx에

<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" %> 

    <%@ Import Namespace="YAF.Classes.Core" %> 


<script runat="server"> 

    protected void Page_Load(object sender, System.EventArgs e) 
    { 

     btnSearch.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(btnSearch, "") + ";this.disabled = true;"); 
     if (forum.PageUserID != 1) 
     { 
      Page.FindControl("divGuest").Visible = false; 
      Page.FindControl("divUser").Visible = true; 
      lblUserName.Text = forum.PageUserName; 
     } 
     else 
     { 
      Page.FindControl("divGuest").Visible = true; 
      Page.FindControl("divUser").Visible = false; 
      lblUserName.Text = null; 
     } 

    } 
    public void Page_Error(object sender, System.EventArgs e) 
    { 
     Exception x = Server.GetLastError(); 
     YAF.Classes.Data.DB.eventlog_create(YafServices.InitializeDb.Initialized ? (int?)YafContext.Current.PageUserID : null, this, x); 
     YAF.Classes.Core.CreateMail.CreateLogEmail(x); 
    } 


    protected void btnSearch_Click(object sender, EventArgs e) 
    { 
     if (txtSearch.Text.Length > 4) 
     { 
      if(ddlCriteria.SelectedValue == "Posts") 
       Response.Redirect("default.aspx?g=search&search=" + txtSearch.Text); 
      if(ddlCriteria.SelectedValue == "Posted By") 
       Response.Redirect("default.aspx?g=search&postedby=" + txtSearch.Text); 
     } 

    } 
</script> 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head id="YafHead" runat="server"> 
    <meta id="YafMetaDescription" runat="server" name="description" content="Yet Another Forum.NET -- A bulletin board system written in ASP.NET" /> 
    <meta id="YafMetaKeywords" runat="server" name="keywords" content="Yet Another Forum.net, Forum, ASP.NET, BB, Bulletin Board, opensource" /> 
    <title>Forums</title> 
    <style type="text/css"> 
    .sbutton 
    { 
    background-color:#361800; 
    border:medium none; 
    border-collapse:collapse; 
    color:#FFFFFF; 
    font-family:Tahoma,Arial,Helvetica; 
    font-size:10px; 
    font-weight:bold; 
    vertical-align:middle; 
    } 
    </style> 
    <link href="images/favicon.ico" type="image/ico" rel="shortcut icon" /> 
    <link rel="stylesheet" href="navTopStyle.css" type="text/css" media="screen" /> 
    </head> 
    <body style="margin: 0"> 
    <form id="form1" runat="server" enctype="multipart/form-data"> 
    <table align="center" style="background-color: #ffffff" cellpadding="0" cellspacing="0" 
     width="790px"> 
     <tr> 
      <td> 
       <!--#include file="CComHeader.html"--> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       <YAF:Forum runat="server" ID="forum"></YAF:Forum> 
      </td> 
     </tr> 
    </table> 
    </form> 
    </body> 
    </html> 

CComHeader.html 포함입니다 이것을 UC로 만들려고했지만 서버 스크립트에서 문제가 발생하여 난처하게 만들지 않았습니다. 더.

답변

4

이 시나리오에서는 IFRAME을 사용할 이유가 없습니다. 이들의 단점은 다음과 같습니다

  • 그들은 크기가 고정되어
  • 그들은 당신이 (스크립트를 수행하기 위해)
  • 그들 항목에 대한 DOM에 액세스 할 수 없습니다 페이지
  • 에 SEO를 위해 포함되지 않습니다

그래서 파일을 "포함"할 것입니다. ASP.NET의 가장 좋은 방법은 User Controls 또는 Master Pages입니다.

+0

하지만 마스터 페이지 나 사용자 정의 컨트롤을 사용해야하는 응용 프로그램에서는 사용하고 있습니다. 이 아이디어는 큰 사이트의 하위 디렉토리에만 해당됩니다. –

+0

마스터 페이지는 "레이아웃"컨테이너입니다. 머리말, 꼬리말, 네비게이션 및 컨텐트를 올바른 형식으로 넣을 수 있습니다. 웹 사이트에 많은 마스터 페이지를 가질 수 있습니다. 사용자 정의 컨트롤은 특정 구성 요소, 즉 고객을 표시하는 방법이어야합니다. 희망이 도움이됩니다. – Fenton

+0

전체 사이트 일 필요는 없지만이 인스턴스에 대해 사용자 정의 컨트롤을 사용할 수 있습니다. – Keltex

1

iframe을 사용하면 클라이언트 브라우저가 내용을 검색하기 위해 다른 HTTP 요청을하게됩니다. 코드를 다른 사람의 웹 사이트에 집어 넣는 것과 같이 특별한 필요가 없다면 iframe을 사용하지 않을 것입니다.

나는 iframe의 요지를 실제로 볼 수는 없지만 나는 제안 할 만하다. 동적 콘텐츠가 필요한 경우 AJAX 및 일반 div를 사용할 수 있습니다. 어떤 이유로 서버가 다른 도메인 또는 서버의 컨텐트를 포함해야하는 경우 컬을 사용할 수 있습니다.

관련 문제