|
查看: 949|回复: 7
|
如何把 php 的 include() 换去 asp.net?
[复制链接]
|
|
|
这是我 php 的 code:
*****************************************************
<html>
<body>
<?
if (isset($_GET['c']){
include("./$_GET[c].php");
}else{
include("./main.php");
}
?>
</body></html>
**************************************************************************
可是,这方法 aspnet 可以吗? |
|
|
|
|
|
|
|
|
|
|
发表于 19-9-2008 09:26 PM
|
显示全部楼层
|
只懂asp.net,不懂php,你可以解释一下那些代码做什么的吗? |
|
|
|
|
|
|
|
|
|
|
发表于 19-9-2008 09:41 PM
|
显示全部楼层
标准的可以使用 ASP.NET Server Control
如果没有使用Event,可以考虑用回旧式的<!-- include --> 不过有限制,和ASP CLassic有点不一样。 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 22-9-2008 11:09 AM
|
显示全部楼层
include 就是把另外一个 php 文件放进去 主 php 文件
eg: fileA.php,
row1. <some code>
row2. <some code>
row3. include("fileB.php"); Row1 fileB.php <some code>
row4. Row2 fileB.php <some code>
row5. Row3 fileB.php <some code>
row6.<some code>
row7.<some code>
fileA.php 里面如果 call include("fileB.php");
那么,fileB.php 里面的所有 code 就会放进去 fileA.php |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 22-9-2008 11:17 AM
|
显示全部楼层
原帖由 o1j2m3 于 19-9-2008 09:41 PM 发表 
标准的可以使用 ASP.NET Server Control
如果没有使用Event,可以考虑用回旧式的 不过有限制,和ASP CLassic有点不一样。
请问有 example 吗? ^-^ |
|
|
|
|
|
|
|
|
|
|
发表于 22-9-2008 09:17 PM
|
显示全部楼层
原帖由 biau_dart 于 22-9-2008 11:09 AM 发表 
include 就是把另外一个 php 文件放进去 主 php 文件
eg: fileA.php,
row1.
row2.
row3. include("fileB.php"); Row1 fileB.php
row4. Row2 fileB.php
row5. Row3 fileB.php
row6.
row7.
fileA ...
i see..
那里面的code都写写什么的?应该不是html element的东西吧?是client side的code?也许你要找的是javascript? |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 23-9-2008 08:41 AM
|
显示全部楼层
原帖由 CryoWraith 于 22-9-2008 09:17 PM 发表 
i see..
那里面的code都写写什么的?应该不是html element的东西吧?是client side的code?也许你要找的是javascript?
其实…………都是php code... 只不过为了好整理,所以都放进了不同的 folder
别人 run 我的 website, 都是跑 index.php
我加了 index.php?content=adduser
那么, index.php 里面就会 include ("adduser.php")
现在玩着 aspnet, 所以看看能不能也沿用这方法 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 23-9-2008 03:58 PM
|
显示全部楼层
ok, 被我发现了这个方法,就放在这里让大家看看~
index.aspx --- coding here
<%@ import Namespace="system.IO" %>
<%@ import Namespace="system.Net" %>
<%@ page language="VB" masterpagefile="~/Site.master" %>
<script runat="server">
Sub page_load()
If (not IsNothing(Request.QueryString("c"))) Then
if (File.Exists(Server.MapPath("./includes/" + Request.QueryString("c") + ".aspx"))) Then
'Response.Redirect("./includes/" + Request.QueryString("c") + ".aspx")
Server.Transfer("./includes/" + Request.QueryString("c") + ".aspx")
'filename = "./includes/" + Request.QueryString("c") + ".aspx"
Else
Server.Transfer("./includes/404.aspx")
End If
End If
End Sub
</script> |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|