从aspx中的div / tables调用函数后面的代码

时间:2014-06-17 14:55:56

标签: asp.net frames

目前我在网页中使用框架,并且我使用src属性调用函数后面的代码。现在我想从我的网页中删除帧。当我用DIV或Table替换帧时,我能否实现相同的方法调用行为?

<FRAME name="nav" marginWidth="0" marginHeight="0" src="<%=fnGetMenuSource()%>" frameBorder="0" 
                noResize scrolling="no">

1 个答案:

答案 0 :(得分:1)

当然,你可以。使用div,你可以这样做:

<div id="divNav" name="nav"><%=fnGetMenuSource()%></div>

在代码中,您可以像这样编写fnGetMenuSource()

protected string fnGetMenuSource()
{
    return "<p style=\"color:red\">Hello World!</p>";
    // Or whatever you need
}

以上代码的输出:

enter image description here