3 asp.net
有没有办法执行完整的ASPX源文件,其中页面源来自字符串/数据库/资源而不是文件系统上的文件?使用HTTP处理程序和模块呈现动态内容/图像/等并写入响应是直截了当的,但似乎没有办法在没有文件系统文件的情况下执行/编译ASPX源.例如:
目标是能够从Handler/Module/ViewEngine执行如下所示的字符串源,而不需要文件系统上的文件(但从其他位置获取源):
<%@ Page language="C#" MasterPageFile="~/Shared/Site.Master" Inherits="System.Web.UI.Page" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ListView Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView Example</h3>
<asp:ListView ID="List" runat="server" DataSourceID="ProductDataSource">
<LayoutTemplate><ol><asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder></ol></LayoutTemplate>
<ItemTemplate><li><%# Eval("ProductName") %></li></ItemTemplate>
</asp:ListView>
<asp:AccessDataSource ID="ProductDataSource" runat="server"DataFile="~/App_Data/Northwind.mdb"SelectCommand="SELECT [ProductName], [QuantityPerUnit], [UnitPrice], [CategoryName] FROM [Alphabetical List of Products]"></asp:AccessDataSource>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
(注意:上面的示例只是一个简单的示例,但显示了使用服务器控件,数据绑定语法,母版页和页面指令中可能的用户控件声明等...)
我希望这是有道理的!
归档时间: |
|
查看次数: |
353 次 |
最近记录: |