收集ASP转ASP.NET过程典型问题

来源:互联网 发布:广告招牌设计软件 编辑:程序博客网 时间:2024/06/05 15:28
1、在asp.net中路径中   "~"   波浪号表示什么含义? 
   A:是你的虚拟目录的根 .
   比如你的虚拟目录是 http://localhost/web  那么   ~/aaa/index.html   就  是  http://localhost/web/aaa/index.html   

2 使用c#给服务器控件的客户端事件绑定JS处理程序的方法? 
 wctl.Attributes.Add("onfocus", string.Format("this.className = ’{0}’;", className));

编程html后的代码为;

onfocus="this.className=’className’"

使用C#代码读取web.config文件中的<connectionStrings>配置节

demo:

 <connectionStrings>
  <add name="test_dbConnectionString" connectionString="Data Source=PROGRAME-8P1PK1;Initial Catalog=test_db;User ID=sa;PassWord=000000"
   providerName="System.Data.SqlClient" />
 </connectionStrings>

1 引用using System.Web.Configuration命名空间

2 string connectionString =ConfigurationManager.ConnectionStrings["dbConnectionString"].ConnectionString;