[英]Dynamic Content Function (callable from front page .aspx, not code behind)
[英]dynamic content for aspx page
我正在嘗試為aspx頁面創建一些動態內容,這是它可能適合我的方向:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test123.aspx.cs" Inherits="Test123" %>
<%=_content %>
我在名為_content的代碼后面有一個受保護的變量,它將提供來自數據庫的doc類型和html內容。
有什么想法或意見嗎? 這是一個好主意嗎? 只要我擦洗動態內容。
除非有理由支持較早的版本,否則也可以使用HTML 5文檔。 這樣,該代碼就不必是動態的。
我不打算解釋為什么應該或不應該在渲染HTML方面在Web窗體或MVC中使您的代碼正常工作的原因。 這是一些示例代碼
using System;
namespace StackOverFlowWebForm
{
public partial class DemoForm : System.Web.UI.Page
{
protected string _content;
protected void Page_Load(object sender, EventArgs e)
{
_content = "<h1>My Dynamic Title<h1>";
}
}
}
后面是示例頁面
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DemoForm.aspx.cs" Inherits="StackOverFlowWebForm.DemoForm" %>
<!DOCTYPE html>
<%=_content %>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.