Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 在vs 2012中使用.aspx中的变量会给出错误类型';System.Web.UI.HtmlControls.HtmlElement';没有定义_Visual Studio_.net 4.5 - Fatal编程技术网

Visual studio 在vs 2012中使用.aspx中的变量会给出错误类型';System.Web.UI.HtmlControls.HtmlElement';没有定义

Visual studio 在vs 2012中使用.aspx中的变量会给出错误类型';System.Web.UI.HtmlControls.HtmlElement';没有定义,visual-studio,.net-4.5,Visual Studio,.net 4.5,我有下面的.aspx代码 <table style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: tahoma"> <tr> <td colspan="2"><%#readfile("header")%><br> <br>

我有下面的.aspx代码

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

此代码用于在VisualStudio2010中成功运行和生成。但现在在VisualStudio2012中,它给出了错误。我怎样才能解决这个问题?即使我将vb中的函数代码替换为返回临时字符串之类的简单操作,我仍然会从.aspx页面中收到错误。

您的所有程序集引用都已就绪吗?

我创建了一个新的Asp.Net vb web forms应用程序,并将您的标记和代码添加到默认页面。即使有一些小问题,我也无法重现您所遇到的错误

不过,我建议您为strHtml指定一个默认值,并从更改为开始


另一个要考虑的问题是你的内容文件(你给那个函数的HTM文件)的确切位置。目前它有点模棱两可,这将导致以后出现问题。

你是说web.config中的配置不足吗?不。在“项目资源管理器”窗口中,项目应该有一个名为“引用”的文件夹。在那里登记。
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