Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.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中从asp.net中的其他页面获取滑块横幅的图像#_C#_Asp.net_Slider - Fatal编程技术网

C# 如何在c中从asp.net中的其他页面获取滑块横幅的图像#

C# 如何在c中从asp.net中的其他页面获取滑块横幅的图像#,c#,asp.net,slider,C#,Asp.net,Slider,这段代码运行良好,但我如何才能给其他网页的实时url像 这是我的代码: protected void Page_Load(object sender, EventArgs e) { string[] filePaths = Directory.GetFiles(Server.MapPath("~/img/landscape")); List<ListItem> files = new List<ListItem>(

这段代码运行良好,但我如何才能给其他网页的实时url像

这是我的代码:

protected void Page_Load(object sender, EventArgs e)
        {
            string[] filePaths = Directory.GetFiles(Server.MapPath("~/img/landscape"));

        List<ListItem> files = new List<ListItem>();
        foreach (string filePath in filePaths)
        {
            string fileName = Path.GetFileName(filePath);
            files.Add(new ListItem(fileName, "img/landscape/" + fileName));
        }

        Repeater1.DataSource = files;
        Repeater1.DataBind();           

    }
受保护的无效页面加载(对象发送方,事件参数e)
{
string[]filepath=Directory.GetFiles(Server.MapPath(“~/img/landscape”);
列表文件=新列表();
foreach(文件路径中的字符串文件路径)
{
字符串fileName=Path.GetFileName(filePath);
添加(新列表项(文件名,“img/landscape/”+fileName));
}
Repeater1.DataSource=文件;
Repeater1.DataBind();
}

如果您有一个外部图像URL数组,您可以直接在中继器中绑定它们。注意,您还没有包含html,因此我假设没有理由使用
ListItem

代码隐藏:

  Repeater1.DataSource = new List<string>{ 
       "http://www.abebooks.com/images/Homepage/cover-art/chicago-1.jpg",
       "http://www.abebooks.com/images/Homepage/cover-art/chicago-3.jpg"
     };

  Repeater1.DataBind();
Repeater1.DataSource=新列表{
"http://www.abebooks.com/images/Homepage/cover-art/chicago-1.jpg",
"http://www.abebooks.com/images/Homepage/cover-art/chicago-3.jpg"
};
Repeater1.DataBind();
然后在标记中:

 <div class="slider container">
      <asp:Repeater runat="server" ID="Repeater1">
           <ItemTemplate>
               <img src="<%# Container.DataItem %>" />
           </ItemTemplate>
      </asp:Repeater>
 </div>

" />