using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
/// <summary>
///Xml 的摘要说明
/// </summary>
public class Xml
{
public Xml()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// XML资源类型
/// </summary>
public enum XmlType
{
File,
String
};
#region 读取XML资源到DataSet中
&nb ......
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
/// <summary>
///Xml 的摘要说明
/// </summary>
public class Xml
{
public Xml()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// XML资源类型
/// </summary>
public enum XmlType
{
File,
String
};
#region 读取XML资源到DataSet中
&nb ......
Public DataTable GetDataTablefromExcel(string fileName,string tableName )
{
string connStr = "Provider=Microsoft.ACE.OLEDB.12.0; Persist Security Info=False;Extended Properties=Excel 8.0; data source=文件路径"
string sql = "SELECT * from [" + tableName + "]";
OleDbConnection conn = new OleDbConnection(connStr);
try
{
conn.Open();
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(sql, connStr);
da.Fill(ds);
}
catch (Exception)
{
throw;
}
finally
{
conn.Close();
}
}
Microsoft.ACE.OLEDB.12.0:odbc驱动程序可以读取*.xls,*.xlsx,*.xlsm,*.xlsb格式的文件。 ......
先看看ASP.NET页面刷新的实现方法:
第一:
private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); } 第二:
private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script language=javascript>window.location.href=document.URL; < /script>" ); } 第三:
private void Button3_Click( object sender, System.EventArgs e ) { Response.AddHeader( "Refresh","0" ); } 第四:
private void Button6_Click( object sender, System.EventArgs e ) { //好像有些不对? //Response.Write( " < script language=javascript>window.location.reload( ); < /script>" ); } 第五:
< script>< !-- var limit="3:00" if ( document.images ) { var parselimit=limit.split( ":" )parselimit=parselimit[0]*60+parselimit[1]*1 } function beginrefresh( ) { if ( !document.images )returnif ( parselimit==1 )window.location.reload( )else { parselimit-=1curmin=Math.floor( parselimit/60 )cursec=parselimit%60if ( curmin!=0 ) ......
此处提供的代码用来实现当asp.net页面中的某个Button被点击后disable掉该页面中所有的Button,从而防止提交延时导致的多次提交。基于之前的onceclickbutton脚本.
//ASP.NET中防止页面多次提交的代码:javascript< script language="javascript"> < !-- function disableOtherSubmit() {
var obj = event.srcElement;
var objs = document.getElementsByTagName('INPUT');
for(var i=0; i< objs.length; i++)
{
if(objs[i].type.toLowerCase() == 'submit')
{
objs[i].disabled = true;
}
}
} //--> < /script>//ASP.NET中防止页面多次提交的代码:asp.netpublic class PreventMultiClick : System.Web.UI.Page {
protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.LinkButton LinkButton1; protected System.Web.UI.WebControls.Button Button3; private void Page_Load(object sender, System.EventArgs e)
{
this.GetPostBackEventReference(this.Button3);
//保证 __doPostBack(eventTarget, eventArgument) 正确注册 if ......
1、首先下载owc11:owc11(http://www.svnhost.cn/Download/Detail-60.shtml)
2、引用OWC:打开"解决方案资源管理器"面板,鼠标右键单击"引用",选择"添加引用"菜单,在弹出的"添加引用"对话框中单击"COM"卡片,找到"Microsoft Office Web Components 10.0(office 2003是11.0)",单击"选择"和"确定"按钮,OWC就被添加到了引用中。
3、建立一个pic.aspx文件,aspx代码如下:
<script language="javascript" type="text/javascript" src="/js/Calendar30.js"></script>
选择开始日期和结束日期。如果时间范围超过365则显示年表,如果时间范围超过30则显示月份表,如果超过1则显示日期表,否则显示小时表。<br />
开始日期:<input id="s" type="text" value="<%= Request.QueryString["s"]%>" onclick="fillDay(this)" >结束日期:<input id="e" value="<%= Request.QueryString["e"]%>" type="text" onclick="fillDay(this)" /><input type="button" value="查看" onclick="location.href='?s='+$F('s')+'&e='+$F('e')" /><br />
<asp:placeholder id="ChartHolder" runat="server"></asp:placeholde ......
ASP.NET生成随机密码
在开发需要用户注册后才能使用提供的各项功能的应用程序时,在新用户提交注册信息后,较常见的做法是由程序生成随机密码,然后发送密码到用户注册时填写的电子信箱,用户再用收到的密码来激活其帐户。
实现ASP.NET生成随机密码功能是很容易的,下面的代码给出了完整的实现方法:
public static string MakePassword(string pwdchars,int pwdlen)
{
string tmpstr="";
int iRandNum;
Randomr nd=new Random();
for(int i=0; i<pwdlen;i++)
{
iRandNum=rnd.Next(pwdchars.Length);
tmpstr+=pwdchars[iRandNum];
}
returntmpstr;
} 对照源码,讲一下具体的思路:
方法 MakePassword 接受两个参数,pwdchars 参数指定生成的随机密码串可以使用哪些字符,pwdlen 指定生成的随机密码串的长度。有了这两个参数,通过调用 Random 类的 Next() 方法,先获得一个大于或等于 0 而小于 pwdchars 长度的整数,以该数作为索引值,从可用字符串中随机取字符,以指定的密码长度为循环次数,依次连接取得的字符,最后即得到所需的随机密码串了。
代码调用 MakePassword() 方法获取长度为 10 ,可用字符范围为大小写字母及数字的 ......