Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.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
C# 从服务器端c访问#include html文件中的html控件#_C#_Asp.net - Fatal编程技术网

C# 从服务器端c访问#include html文件中的html控件#

C# 从服务器端c访问#include html文件中的html控件#,c#,asp.net,C#,Asp.net,下面的代码是一个例子,我只是想知道这是否可以做到 我有一个test.aspx文件,带有这个服务器端的include标记 <!--#include file="listOfCountries.htm" --> 在listOfCountries.htm中,我有: <html> <div> <select id="countryList" runat="server"> <option></option> ... </

下面的代码是一个例子,我只是想知道这是否可以做到

我有一个test.aspx文件,带有这个服务器端的include标记

<!--#include file="listOfCountries.htm" -->

在listOfCountries.htm中,我有:

<html>
<div>
<select id="countryList" runat="server">
<option></option>
...
</select>
</div>
</html>

...
现在,有办法访问test.aspx.cs文件中的“countryList”吗


另一方面,假设我没有test.aspx中的#include“Countries.htm”,那么可以从test.aspx.cs访问Countries.htm中的控件吗?(即访问cs中的外部html文件控件)

据我所知,您所要求的是不可能的,因为包含文件实际上没有解析为asp.net

您要做的是创建一个“用户控件”,方法是右键单击项目,选择“添加新项目”,然后从出现的窗口中选择“Web用户控件”


在用户控件中,您可以定义“countries.htm”的标记,然后将的内容公开给您的C代码。

解决方案是不使用服务器端包含(
\include
)。没有其他人这样做。请改用用户控件。谢谢,您必须引导我学习Web用户控件,这似乎解决了我的问题。。感谢你的帮助。。。任何有更多信息的网站-或者在msdn上查找是获得更多信息的最佳选择?