0

我有以下 .aspx 代码

<table style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: tahoma">
                    <tr>
                        <td colspan="2"><%#readfile("header")%><br>
                            <br>
                        </td>
                    </tr>
                    </table>

我正进入(状态

未定义类型“System.Web.UI.HtmlControls.HtmlElement”。

在 <%#readfile("header")%> 行上。

Public Function readfile(ByVal filename)
    Dim objstreamReader As StreamReader
    Dim strHtml As String
    Dim  phypath =  filename & ".htm"
    If File.Exists(phypath) Then
        objstreamReader = File.OpenText(phypath)
        strHtml = objstreamReader.ReadToEnd
        objstreamReader.Close()
    End If
    readfile = strHtml
End Function

此代码曾经在 Visual Studio 2010 中成功运行和构建。但现在在 Visual Studio 2012 中它给出了错误。我该如何解决?即使我将 vb 中的函数代码替换为简单的东西,比如返回一个临时字符串,我仍然会从 .aspx 页面收到错误。

4

2 回答 2

0

I've created a new Asp.Net VB web forms application and added your markup and code to the default page. Even though there are some minor issues I could not reproduce the error you are getting.

I do suggest though that you assign a default value to strHtml and change <%#readfile("header")%> to <%:readfile("header")%> as a start.

another thing to consider is where exactly you content files (the htm files you are feeding to that function) are located. Currently it's a bit ambiguous which will cause problems later on.

于 2013-06-05T11:09:00.693 回答
0

您的所有装配参考都到位了吗?

于 2013-05-30T07:17:22.007 回答