【发布时间】:2011-11-17 23:52:04
【问题描述】:
对加载保存在数据库中的 html 页面有什么建议吗?
html:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>xxx</title>
</head>
<body>
<form id="Form1" runat="server" method="post">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
</form>
</body>
代码隐藏:
protected override void OnInit(EventArgs e)
{
this.IniciarFormulario();
using (ServicoECMClient proxy = new ServicoECMClient())
{
tipoDocumento = proxy.ObterTipoDocumento(int.Parse(tipoDocumentoID));
}
if (tipoDocumento == null)
{
throw new ApplicationException();
}
this.Page.Header.InnerHtml = tipoDocumento.estilo; //css
this.Page.Form.InnerHtml = tipoDocumento.form; // form
base.OnInit(e);
}
我无法检索表单值。
看:
foreach (System.Web.UI.Control controle in this.Form1.Controls)
{
if (controle.GetType().Name == "HtmlInputText" || controle.GetType().Name == "HtmlInputSelect"
|| controle.GetType().Name == "HtmlInputRadio" || controle.GetType().Name == "HtmlInputTextCheckbox")
{
if (!string.IsNullOrEmpty(this.Request[controle.ClientID]))
{
documento_indice documentoIndice = new documento_indice();
documentoIndice.id_indice = int.Parse(controle.ClientID.Split('_')[1]);
documentoIndice.valor = this.Request[controle.ClientID];
documentoIndice.timestamp = DateTime.Now;
documentos_indices.Add(documentoIndice);
}
}
}
控件为空。 => this.Form1.Controls
有什么建议吗?
还有其他更好的方法吗?
谢谢。
【问题讨论】:
-
这是一个html页面。开头没有任何 Aspx 标记表明这是从后面的代码派生的,也不表明该页面甚至被编译;因此,它永远不会出现在后面的代码中。 HTML 是否完整?
-
如果您只想从数据库中渲染出原始 html,只需使用处理程序 (ashx) 文件和 Response.Write() 输出 HTML。
-
查看 VirtualPathProvider msdn.microsoft.com/en-us/library/…
-
大家好,@kurtnelle 这是我的 aspx 页面。我在这里完成(this.Page.Header.InnerHtml = tipoDocumento.estilo; //css this.Page.Form.InnerHtml = tipoDocumento.form; // form )不要把所有的实现都放在这里。但我可以访问代码隐藏。
标签: c# asp.net html controls dynamic-html