时间:2016-02-16 02:30 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【ASP.NET 服务器路径和一般资源调用】,下面是详细的讲解!
ASP.NET 服务器路径和一般资源调用
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CDataBase;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
/// <summary>
/// 页面加载事件
/// </summary>
/// <param name="sender">控件发送对象</param>
/// <param name="e">事件对象</param>
protected void Page_Load(object sender, EventArgs e)
{
//取得ConnectionString的值
//Response.Write("<script>alert('" + SqlHelper.conString + "')</script>");
if (!IsPostBack)
{
//先要有路径 系统根目录下 福娃文件夹 下的文件路径
string sPath=Server.MapPath(Request.ApplicationPath + "/福娃/");
//取得这个路径下面所有的文件名 包含其路径
string[] sFiles=Directory.GetFiles(sPath);
//循环所有文件的路径
foreach (string sFile in sFiles)
{
//取文件名
string sName=Path.GetFileNameWithoutExtension(sFile);
//取文件名, 包含扩展名
string sFileName=Path.GetFileName(sFile);
//建立RadioButtonList的子项,采用 Text/Value 的重载方式
ListItem rItem=new ListItem(sName, Request.ApplicationPath + "/福娃/" + sFileName);
//将子项添加到RadioButtonList里
RadioButtonList_Demo.Items.Add(rItem);
}
//设置RBL中单选按钮的显示排列方式
RadioButtonList_Demo.RepeatDirection=RepeatDirection.Horizontal;
RadioButtonList_Demo.RepeatLayout=RepeatLayout.Table;
}
}
/// <summary>
/// 选择项改变事件
/// </summary>
/// <param name="sender">控件发送对象</param>
/// <param name="e">事件对象</param>
protected void RadioButtonList_Demo_SelectedIndexChanged(object sender, EventArgs e)
{
Image_Show.ImageUrl=RadioButtonList_Demo.SelectedValue.ToString();
}
}
关于ASP.NET 服务器路径和一般资源调用的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 【asp】asp.net url重写浅谈-net-url重写
- 【DataSet】DataSet、DataTable、DataRow区别详解
- 【asp】asp.net 动态添加多个用户控件-net-动态添
- 【ASP】ASP.NET中内嵌页面代码的一个问题-NET-内
- 【As】Asp.net中的页面乱码的问题-sp--pn-ne-et
- 【增加记录】asp.net中获取新增加记录的ID Access
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【Asp】Asp.net 页面调用javascript变量的值-net-
- 【ASP】ASP.NET 5升级后如何删除旧版本的DNX-NET5
- 【404页面】ASP.NET设置404页面返回302HTTP状态码
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
