如何运行从数据库中检索的asp代码 [英] How to run asp code, retrieved from the database
问题描述
我的ASP项目中只有一个页面,在点击其他链接后,我从数据库中检索相应的HTML并加载它。所以我有一些链接,它们始终位于页面中(HTML中未从数据库中检索到的部分)但在某些div中我得到了HTML,在那里我也有链接,我就是喜欢以ASP LinkButton控件的形式运行。
这是,fe,总是保持:
< pre lang =HTML> < div id = mainCenter < span class =code-keyword>>
< asp:Literal ID = ltlContentCenter runat = server / > ;
< / div >
所以在我的代码背后我有这个:
受保护 void Page_Load( object sender,EventArgs e){
ltlContentCenter.Text = getPageCenter( media) ; // 检索的函数
ltlContentSide.Text = getPageSide( media); // 数据库中的HTML
}
我在数据库中的相应内容是:
< div class = onCenterSmall >
< asp:LinkButton < span class =code-attribute> ID = LinkButton10 文字 = test CommandArgument = test OnCommand = loadPage_Command
runat = server / > ;
< / div >
< div class = onCenterSmall > < / div >
< div class = onCenterSmall > < / div >
大块的HTML只是放在
< div id = mainCenter > <! - 此处 - > < / div >
在页面上。正如你自己可以看到的,我得到的结果是字符串。对于HTML代码很好,但对于
< asp:LinkButton ... >
这不太有效。有什么建议我怎么能以同样的方式完成所有的工作(或者至少保留逻辑)但是让LinkButton控件工作?
Checkout ParseControl < a href =https://www.google.com/search?q=.NET+ParseControl> https://www.google.com/search?q=.NET+ParseControl [ ^ ]
I have one single page in my ASP project, where upon clicking a different link, I retrieve ,from the database, the according HTML and load it. So I have some links, that are sitting in the page at all time (the part of the HTML that is not retrieved from the DB) but in some divs I get the HTML, and in there I also have links, that I'd like to run as ASP LinkButton controls.
This is, f.e., that always stays:
<div id="mainCenter">
<asp:Literal ID="ltlContentCenter" runat="server" />
</div>
So in my code behind I have this:
protected void Page_Load(object sender, EventArgs e) {
ltlContentCenter.Text = getPageCenter("media"); //function that retrieves
ltlContentSide.Text = getPageSide("media"); // the HTML from the database
}
What I have in the DB, corresponding, is:
<div class="onCenterSmall">
<asp:LinkButton ID="LinkButton10" Text="test" CommandArgument="test" OnCommand="loadPage_Command"
runat="server" />
</div>
<div class="onCenterSmall"></div>
<div class="onCenterSmall"></div>
That chunk of HTML just gets put in between the
<div id="mainCenter"><!-- in here --></div>
on the page. And as you can see by yourself I get the result as string. For the HTML code that's fine, but for the
<asp:LinkButton...>
that doesn't quite work. Any suggestions how I can do all the work in the same way (or at least to preserve the logic) but to get the LinkButton control working ?
Checkout ParseControl https://www.google.com/search?q=.NET+ParseControl[^]
这篇关于如何运行从数据库中检索的asp代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!