Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.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
Asp.net 在头中插入文字控件时<;头运行时间=”点;服务器"&燃气轮机;是否未指定?_Asp.net_Webforms_Page Lifecycle - Fatal编程技术网

Asp.net 在头中插入文字控件时<;头运行时间=”点;服务器"&燃气轮机;是否未指定?

Asp.net 在头中插入文字控件时<;头运行时间=”点;服务器"&燃气轮机;是否未指定?,asp.net,webforms,page-lifecycle,Asp.net,Webforms,Page Lifecycle,由于各种原因,我无法标记我的标记runat=“server”。有没有其他方法可以让我访问它并在它下面附加一个文本?我需要添加一个脚本(作为文本),并将其作为标记内部引用的第一个脚本 可能使用FindControl?可以声明服务器控件,而不将head元素定义为服务器控件: <head> <asp:Literal ID="literal1" runat="server"></asp:Literal> <title></title&

由于各种原因,我无法标记我的
标记
runat=“server”
。有没有其他方法可以让我访问它并在它下面附加一个文本?我需要添加一个脚本(作为文本),并将其作为
标记内部引用的第一个脚本

可能使用FindControl?

可以声明服务器控件,而不将head元素定义为服务器控件:

<head>
    <asp:Literal ID="literal1" runat="server"></asp:Literal>
    <title></title>
</head>

使用此选项,您可以根据需要从代码隐藏中添加内容:

protected void Page_Load(object sender, EventArgs e)
{
    literal1.Text = "<script type=\"text/javascript\" src=\"scripts.js\"></script>";
}
受保护的无效页面加载(对象发送方,事件参数e)
{
literal1.Text=“”;
}

您只能使用
FindControl
查找控件,即作为服务器控件的元素。所有其他元素在文本控件中仅作为文本处理

您可以在head标记中放置一个
占位符
控件,然后可以在其中添加文字控件