sirve que para mvc for eventos atributo asp.net vb.net webforms code-behind html

asp.net - que - razor c#



Agregar atributo a la etiqueta html a través de los resultados de código subyacente en el tipo de error(System.Web.UI.HtmlControls.HtmlElement) no es compatible (1)

Cuando intento agregar un atributo a mi etiqueta html en mi página maestra:

<!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">

al igual que en el código detrás:

prmimaryhtml_tag.Attributes.Add("lang", "en")

Me sale este error:

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

También revisé main.master.designer.vb y contiene esta línea:

Protected WithEvents primtag As Global.System.Web.UI.HtmlControls.HtmlElement

Ahora, lo más extraño es que este código funciona correctamente en mi máquina local, pero no en mi servidor de producción. No sé qué está causando este comportamiento diferente tampoco.

También miré esta publicación: establecer la etiqueta html principal de páginas en c #

ACTUALIZACIÓN Cuando mi situación es la siguiente:

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

comentó esta línea:

''primtag.Attributes.Add

Yo obtengo:

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>

Después de eso intenté cambiar esa línea en el archivo main.master.designer.vb de la etiqueta primaria Protected WithEvents primtag As Global.System.Web.UI.HtmlControls.HtmlElement a la Protected WithEvents primtag As Global.System.Web.UI.HtmlControls.HtmlElement Protected WithEvents primtag As Global.System.Web.UI.HtmlControls.HtmlGenericControl activado el servidor de producción que obtengo:

Object reference not set to an instance of an object.

ACTUALIZACIÓN 2

Puede tener algo que ver con la compilación de mi solución, también revisé estas publicaciones:

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

Luego compruebo mi configuración de IIS7.5 en la máquina local, allí el grupo de aplicaciones se estableció en ASP.NET4.0, igual que en mi servidor de producción. Mi compilación de marco de destino en Visual Studio está configurada en .NET Framework 4.5.

Esperemos que esto proporcione más ideas para hacer que esto funcione. Por favor ayuda :)


Posiblemente, cada atributo agregado dinámicamente debería comenzar con cualquier prefijo especial (por ejemplo, el "xml").

Verifique este hilo, que puede ser útil.