พบกับบทความเกี่ยวกับคอมพิวเตอร์และ programming ได้ที่ http://articles.modoeye.com | บล็อกอาหาร
ASP programming / ปัญหาใหญ่หลวง เกี่ยวกับการ Include ไฟล์ ใน IE
saksiri
saksiri
Mon 2 Oct 2006 18:33:39
คือผมใช้ asp กับ Java scrip แล้ว ส่วนของหัว web ผมทำเป็นไฟล์ต่างหาก พอในแต่ละหน้าของ web ผมใช้วิธี Include ไฟล์ หัวเข้ามา แบบนี้


<!--#include file="head.asp" -->

โดยผมเอาไว้ในส่วน Header ครับ


ตอนทำก็ใช้ browser FireFox ก็ ใช้ได้ครับ แต่พอ เอามา run บน IE กับเดี่ยงใช้การไม่ได้เลย กดปุ่มไปหน้าอื่นๆ ก็ไม่ได้ ทำไงดีครับ

ช่วยด้วยครับ ขอบคุณ
Administrator
Mon 2 Oct 2006 23:09:31
ที่ว่าใช้ไม่ได้ใน ie นั้นคือ menu ที่เป็น javascript ใช่หรือไม่ครับ อย่างไรแล้วลองเอา HTML code ที่แสดงบน browser มาดูครับ
saksiri
saksiri
Tue 3 Oct 2006 08:18:19
อันนี้เป็น ส่วนของ Header ครับ เป็น menu ของ web ไฟล์ชื่อ Head.asp

<html>
<head>
<script LANGUAGE="JavaScript">
<!-- Begin
var n = 0;
timedelay = 15; // 3 secs between pics
timedelay *= 1000;
var imgs = new Array();
imgs[0] = "Picture/BX/BX0006M.jpg";
imgs[1] = "Picture/BX/BX0007M.jpg";
imgs[2] = "Picture/BX/BX0001L.jpg";
imgs[3] = "Picture/DI/DI0006L.jpg";
imgs[4] = "Picture/DI/DI0009S.jpg";
imgs[5] = "Picture/DI/DI0011S.jpg";
imgs[6] = "Picture/HT/HT0007.jpg";
imgs[7] = "Picture/HT/HT0013.jpg";
imgs[8] = "Picture/HT/HT0013.jpg";
imgs[9] = "Picture/HT/HT0018.jpg";
imgs[10] = "Picture/HT/HT0013.jpg";
imgs[11] = "Picture/PG/PG0002.jpg";
imgs[12] = "Picture/ST/ST0005.jpg";
function rotate() {
 document.picform.slideshow.src = imgs[n];
 (n == (imgs.length - 1)) ? n = 0 : n++;
    window.setTimeout("rotate()", 1000);
}

window.onload = rotate;
// End -->
</script>
<title>Document Header</title>

<meta http-equiv="Content-Type" content="text/html; charset=tis-620"></head>
<body background="Picture/DHappening1.jpg">

<TABLE width="100%" border=0  background="Picture/Clara Blue 63002.jpg">
                    <TBODY>
                      <TR>
                           <TD width=12% height=100 background="Picture/Clara Blue 63002.jpg" ><div align="center">
                              <Image src="Picture/DHappening.jpg" width=79 height=77 border=0>
                          </TD>
                          <TD  width=76% height=100 background="Picture/Clara Blue 63002.jpg"><div align="center"><B><I><FONT color="#7CFC00" size=6 face="Asans-serif">D-HAPPENING</FONT></I></B></div></TD>
                          <TD width=12% height=100 background="Picture/Clara Blue 63002.jpg"><div align="center">
                           <form name="picform">
                            <img name="slideshow" src="../Picture/DHappening.jpg" " width=79 height=77 border=0>
                           </form>           
                          </div></TD>
                      </TR>
                    </TBODY>
                  </TABLE>
<table width="100%" border="1" bgcolor="#D15FEE">
  <tr>
    <td Background= "Picture/HollyHock-66004_1.jpg" windth=15% ><a href="Home.asp" >Home </a></td>
    <td Background="Picture/HollyHock-66004_1.jpg"  windth=20%><a href="Find_Material.asp">ข้อมูลวัสดุ</a></td>    
    <td Background="Picture/HollyHock-66004_1.jpg" windth=20%><a href="Find_Product.asp">ข้อมูลสินค้า</a></td>
    <td  Background="Picture/HollyHock-66004_1.jpg" windth=15%><a href="Default.asp?session("Login")="false">LogOff</a></td>    
    <td Background="Picture/HollyHock-66004_1.jpg" windth=15%><a href="\../Prophesy\Ee-gin.asp">ดูหมอ</a></td>
    <td Background="Picture/HollyHock-66004_1.jpg" windth=15%><a href="Download.asp">Download</a></td>
    
  </tr>
</table>
</body>
</html>
 
saksiri
saksiri
Tue 3 Oct 2006 08:45:10
ใน Head.asp จะเป็นส่วนเมนู และมีการแสดงภาพสินค้าที่เปลี่ยนไปมา (Java script) นอกจากนี้มีการ Include อีกไฟล์ คือส่วนสำหรับ Connect Databas (Access) ผมขี้เกียจเขียนทุกหน้าเลย Include เอา ชื่อไฟล์ Connect_Data.asp

<head>
<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=tis-620"><body>

<%
'Database Connection Preparation
accessdb="data.mdb"
myDSN="PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" & server.mappath(accessDB) & "; USER ID=;PASSWORD=;"
'--------------------------------------------
'  Database Connection
Set conn = Server.CreateObject("ADODB.Connection")
conn.open myDSN
%>
</body>
</html>

saksiri
saksiri
Tue 3 Oct 2006 08:53:52
อันนี้เป็นส่วนของโปรแกรมครับ คือผมกดปุ่ม Submit แล้วมันไม่ไปอีกหน้า ตาม tac <form ...ครับ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ LANGUAGE = "VBScript" %>
<html>
<head>
<title>Find Data Custom</title>
<!--#include file="head.asp" -->
<!--#include file="Connect_Data.asp" -->
<%
Response.Write vbCrLf & "<meta name=""copyright"" content=""Copyright (C) 2002-2005 Supap Wanawan"" />"
Response.Write vbCrLf & ""
Response.Write vbCrLf & "<META http-equiv=""Content-Type"" content=""text/html; charset=windows-874"">"
Response.Write vbCrLf & "<META http-equiv=""Content-Type"" content=""text/html; charset=tis-620"">"
Response.Write vbCrLf & "<META http-equiv=""Content-Language"" content=""th"">"
Response.Write vbCrLf & "<META http-equiv=""Content-Language"" content=""en"">"
%>

</head>
<body>
<%if  session("Login") then%>
  <form name="submit" method="post" action="Find_MaterialResult.asp">
<%

     Session.Contents.Remove("MType")
     Session.Contents.Remove("MCode")
     Session.Contents.Remove("MName")
     Session.Contents.Remove("MOldCode")

     strSql=" Select PMaterial_Type.*  From PMaterial_Type;"
     Set rs1 = Server.CreateObject("ADODB.Recordset")
     rs1.Open strSql, conn, 3, 3
%>
     <div align="center">
    <table width="100%" border="0">
    <tr bgcolor="#CCCCFF">
    <td>
    <%
     response.write "ประเภทวัสดุ : "
     response.write "<select  name=""MType"" >"
 
    if MType = "" then
       response.write "<option value="""" Selected></option>"
    end if        
    do while not rs1.eof
     %>
      <Option value="<%=rs1("MType")%>"  ><%response.write  rs1("TypeName")   %></Option>
      <%      
       rs1.movenext
     loop
     %>  
      </select>   
     </td>
    <td>      
      รหัสวัสดุ<input type="text" name="MCode" size = 10 value =<%=PCode%>>
      ชื่อวัสดุ : <input type="text" name="MName" value=<%=PName%>>
      รหัสเก่า : <input type = "text" name ="MOldCode" size = 10 Value=<%=POldCode%>>
      <input type="submit" name="Submit" value="ค้นข้อมูล">
      </td>
        </tr>
     </table>
     <%
     Citeria =""
      Sql=" Select Product.* ,PMaterial_Type.TypeName From Product  Inner Join PMaterial_Type on Product.Ptype = PMaterial_Type.MType"
      sql = Sql +"  ORDER BY Product.ProCode;"
 
       Set rs = Server.CreateObject("ADODB.Recordset")
       rs.Open Sql, conn, 3, 3
       RecPerPage = 9
       rs.PageSize = RecPerPage+1
       RecordAmount = rs.recordcount
       PageAmount = rs.PageCount
    
       If Request.QueryString("PagePosition") = "" or Request.QueryString("PagePosition")  < PageAmount or Request.QueryString("PagePosition") = "0" Then
          PositionPageNum = 1
       Else
         PositionPageNum= CInt(Request.QueryString("PagePosition"))
      End If

     If NOT rs.EOF Then rs.AbsolutePage = PositionPageNum
       response.write "<table width=""100%"" border=""0"">"
       response.write "<tr>"
       response.write "<td width=""40%"" align=""Left"" ><font  size=""2"">ทั้งหมด <font color=""red"" size=""2"">" & RecordAmount  & "</font> รายการ มีทั้งหมด    <font color=""red"" size=""2""> " & PageAmount & "</font> หน้า และคุณกำลังอยู่ในหน้าที่ <font color=""red"" size=""2"">"  & PositionPageNum & "</font> </font> </td>"
       response.write "<td width=""20%"" align=""center"" ><font size =""3"" color=""#FF0000""><strong>ลบหรือแก้ไขข้อมูลวัสดุ</strong></font></td>"
       Response.Write "<td width=""40%"" align=""Right""><font size=""2"">"
       If PositionPageNum > 1 Then
         Response.Write "<a href=""Find_Material.asp?PagePosition=1"">หน้าแรก</a> &nbsp;"
         Response.Write "<a href=""Find_Material.asp?PagePosition="&  PositionPageNum + 1 &""">ถัดไป</a> &nbsp;"         
         Response.Write "<a href=""Find_Material.asp?PagePosition="& PositionPageNum - 1 &""">หน้าย้อนหลัง</a> &nbsp; "
         Response.Write "<a href=""Find_Material.asp?PagePosition="& PageAmount &""">หน้าสุดท้าย</a>"         
       Else 
         If PositionPageNum < PageAmount Then
           Response.Write "<a href=""Find_Material.asp?PagePosition="&  PositionPageNum + 1 &""">ถัดไป</a>]&nbsp;"
           Response.Write "<a href=""Find_Material.asp?PagePosition="& PageAmount &""">หน้าสุดท้าย</a>"
         End if 
       End If
       response.write "</font></td></tr></table>"
       response.write "ไปหน้าที่ "
       For PageLoopCounter = 1 to PageAmount
         If PageLoopCounter = PositionPageNum Then
            Response.Write "<font color=""red"" size=""2""><b>"& PageLoopCounter &"</b></font>"
         Else        
            Response.Write "<font color=""red"" size=""2""><a href=""Find_Material.asp?PagePosition="& PageLoopCounter &""">"& PageLoopCounter &"</a>&nbsp;</font>"
         End If
          Next     

       response.write "<table border=""1""  width=""100%"" >"
       response.write "<tr bgcolor=""skyblue"">"
       response.write "<td align=""center"" width=""8%""><strong><font size=""2"" color=""#0000FF"">ประเภทวัสดุ</fontt></strong></td>" 
       response.write "<td align=""center"" width=""8%""><strong><font size=""2"" color=""#0000FF"">รหัสวัสดุ</fontt></strong></td>"
       response.write "<td align=""center""  width=""16%""><strong><font size=""2"" color=""#0000FF"">ชื่อวัสดุ</fontt></strong></td>"
       Response.write "<td align=""center"" width=""8%""><strong><font size=""2"" color=""#0000FF"">รหัสวัสดุเก่า</fontt></strong></td>"
       Response.write "<td align=""center""  width=""5%""><strong><font size=""2"" color=""#0000FF"">หน่วย</fontt></strong></td>" 
       Response.write "<td align=""center"" width=""5%""><strong><font size=""2"" color=""#0000FF"">Size</fontt></strong></td>"
       Response.write "<td align=""center""><strong><font size=""2"" color=""#0000FF"">แก้ไข</fontt></strong></td>"     
       Response.write "<td align=""center""><strong><font size=""2"" color=""#0000FF"">ลบ</fontt></strong></td>" 
       Response.write "</tr>"

       'bColor = "#CCFFFF"  
       bColor = "#FFDEAD"  
       do while not rs.eof and RecordNumbe <=RecPerPage
          RecordNumber = 1
          if bColor = "#FFDEAD"  then
             bColor = "#EEA2AD"
         else
             bColor = "#FFDEAD"  
         end if   
         response.write "<tr  bgcolor=" & bColor & ">"
         response.write "<td align='center' width=""8%""><font size='2'>" & rs("PType") & "</a></font></td>"
         response.write "<td align='center'  width=""8%""><font size='2'>" & rs("ProCode") & "</a></font></td>"        
         response.write "<td align='center' width=""16%""><font size='2'>" & rs("PName") & "</a></font></td>"   
         response.write "<td align='center' width=""8%""><font size='2'>" & rs("Record") & "</a></font></td>"     
         response.write "<td align='center' width=""5%""><font size='2'>" & rs("Unit") & "</a></font></td>"     
         response.write "<td align='center' width=""5%""><font size='2'>" & rs("Size") & "</a></font></td>"           
         response.write "<td align='center'><font size='2'><a href='Edit_Material.asp?PCode=" & rs("PCode") & "' target='_parent'>Edit</a></font></td>"'
          response.write "<td align='center'><font size='2'><a href=""#"" onClick=""NewWin=window.open('del.asp?PCode=" & rs("PCode") & " ','MENU','toolbar=no,status=no, width=200, height=180'); "">Delete</a></font></td>"     
           response.write "</tr>"
         RecordNumbe=RecordNumbe+1     
         rs.movenext
       loop
       response.write "</table>"
 
       rs.close
       set rs = nothing
       conn.close
       set conn = nothing

    %>

   </form>
    <center>
   <form name="AddData"  action="Add_Material.asp">
     <input type="submit" name="AddData" value="เพิ่ม"  runat="server" style="background-color:#CC99FF">
   </form>
   </center>
   <%
  else
     response.write "<center><br><br>"
     response.write "<font size=""4"" color=""Red"">คุณไม่ได้ใช้งานในเวลาที่กำหนด กรุณา Logon ใหม่อีครั้ง </font>"
     response.write "<br><a href =""Default.asp"">Log In </a></center>"
  end if
  %>
</body>
</html>

Administrator
Tue 3 Oct 2006 11:34:03
1. <img name="slideshow" src="../Picture/DHappening.jpg" " width=79 height=77 border=0>

มี double-quote เกินมาหนึ่งตัวครับ ทำให้ tag อื่นๆถูกมองว่าเป็น properties ของ image ทั้งหมดครับ

2. <td  Background="Picture/HollyHock-66004_1.jpg" windth=15%><a href="Default.asp?session("Login")="false">LogOff</a></td>

attribute href ไม่มี double-quote ปิดครับ
หนามเตย
หนามเตย
Sun 13 Jan 2008 16:33:09

ไฟล์ ที่จะ include มา ไม่จำเป็นต้องมี tag html อื่นๆ ก็ได้ เช่นพวก

<html>
<head>
.....
.....
</html>

เพราะการ include ไฟล์ ก็คือการ เอา Code ที่ include มาแปะเข้าไป
ถ้ามีพวก นี้มาด้วย มันก็ซ้ำซ้อนกันเปล่าๆ

Reply
Name:
E-mail:
Home | Services | Forum | Classified | Directories | Support | Contact
ATOM feed RSS 0.9 feed RSS 1.0 feed RSS 2.0 feed
Copyright © 2005 - 2007 Modoeye.com, All Rights Reserved.
Disclaimer | Privacy policy | Term of Use | Term of Services
Valid XHTML Valid CSS! PHP: Hypertext Preprocessor MySQL database Apache Powered! FreeBSD Power to serve
Modoeye Sitemap Client login