当我尝试在我的母版页中向我的html标记添加属性时:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" id="primtag" runat="server">
像代码背后一样:
prmimaryhtml_tag.Attributes.Add("lang","en")
我收到此错误:
Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: The base class includes the field 'primtag',but its type (System.Web.UI.HtmlControls.HtmlElement) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlGenericControl). Source Error: Line 4: Line 5: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Line 6: <html xmlns="http://www.w3.org/1999/xhtml" id="primtag" runat="server"> Line 7: <head id="Head1" runat="server"> Line 8: <title></title> Source File: /main.master Line: 6
我还检查了main.master.designer.vb并保留了这一行:
Protected WithEvents primtag As Global.System.Web.UI.HtmlControls.HtmlElement
现在,最奇怪的是:这个代码在我的本地机器上正常工作,但在生产服务器上却没有.我不知道是什么导致了这种不同的行为.
我也看过这篇文章:set pages main html tag in c#
UPDATE
我的情况如下:
main.master.designer.vb
Protected WithEvents primtag As Global.System.Web.UI.HtmlControls.HtmlElement
main.master.aspx
<html xmlns="http://www.w3.org/1999/xhtml" ID="primtag" runat="server">
main.master.aspx.vb
评论这一行:
'primtag.Attributes.Add
我明白了:
Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: The base class includes the field 'primtag',but its type (System.Web.UI.HtmlControls.HtmlElement) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlGenericControl). Source Error: Line 4: Line 5: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Line 6: <html xmlns="http://www.w3.org/1999/xhtml" ID="primtag" runat="server"> Line 7: <head id="Head1" runat="server"> Line 8: <title></title>
之后我尝试将main.master.designer.vb文件中的那一行从Protected WithEvents primtag更改为Global.System.Web.UI.HtmlControls.HtmlElement to Protected WithEvents primtag As Global.System.Web.UI.HtmlControls.HtmlGenericControl On我得到的生产服务器:
你调用的对象是空的.
更新2
它可能与我的解决方案的编译有关,我还检查了这些帖子:
http://briancaos.wordpress.com/2013/08/07/system-web-ui-htmlcontrols-htmliframe-is-not-compatible-with-the-type-of-control-system-web-ui-htmlcontrols-htmlgenericcontrol/ https://connect.microsoft.com/VisualStudio/Feedback/details/736011/iframe-parser-error http://forums.asp.net/t/1884696.aspx?help+required+with+iframes+on+aspx http://support.microsoft.com/kb/941824 http://forums.asp.net/t/1686949.aspx
然后我检查本地机器上的IIS7.5设置,应用程序池设置为ASP.NET4.0,与我的生产服务器上的相同.
我在Visual Studio中的目标框架编译设置为.NET Framework 4.5.
希望这为实现这一目标提供了更多见解.请帮忙 :)
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。