关于asp.net的配置文件
配置文件可用来存放一些多次用到的常量数据,如连接串:
<appSettings>
<add key="connStr1" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="/>
<add key="connStr2" value="App_Data\test.mdb"/>
</appSettings>
这个配置数据库连接串
使用示例:
public class DBConn
{
protected OleDbConnection _conn;
public DBConn(System.Web.UI.Page page)
{
string path = page.Server.MapPath(ConfigurationSettings.AppSettings["connStr2"]);
string connectString = ConfigurationSettings.AppSettings["connStr1"];
connectString += path;
_conn = new OleDbConnection(connectString);
_conn.Open();
}
........
<system.web>
<compilation debug="true" />
这个配置网站为DEBUG模式
<authentication mode="Windows"/>
这个配置为WINDWOS认证模式。
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
这个配置403,404出错时的传回页面
配置网站邮件服务器:
<mailSettings>
<smtp from="pclion2008@googlemail.com">
<network host="smpt.gmail.com" userName="" password=""/>
</smtp>
诸如此类。都是一些常量参数,因为多次用到这些参数,所以写在配置文件中用起来就方便多了。甚至某些临时数据也可以从程序中写入,让另一网页访问
相关文档:
1.上传功能
JS检查
function hideUpImg()//关闭层,并上传图片
{
var v=document.getElementById("upImg").value;
var after=v.substring(v.lastIndexOf('.')).toLowerCase();
alert(after);
if(v.length<=0)
{
alert("请选择图片");
return ......
文章出处:http://www.cnblogs.com/tomcat112906/articles/922639.html
ASP.NET的HTMLTable原样导出到Excel
js代码 : function PrintTableToExcelEx(objTab)
{
&nbs ......
asp.net中“线程正被中止”异常的解决方法
在项目里负责异常处理部分:异常信息的写入,读取,查看,因此就可以看到各种异常,受益匪浅
看到有N多的“线程正被中止”异常,而且来自同一个页面。
System.Threading.ThreadAbortException: 线程正被中止。
at System.Threading.Thread.AbortInternal( ......
前台:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
......
方法1:
比如建立一个名为cnlive,值为"123"的cookie
HttpCookie cookie = new HttpCookie["cnlive"];
cookie.Value = "123";
Response.AppendCookie(cookie);
取刚才写入的Cookie值:
HttpCookie cookie = Request.Cookies["cnlive"];
cookieValue = cookie.Value;
在一个Cookie中储存多个信息:
HttpCookie cookie ......