Time of Update: 2018-12-08
'************************************* '檢測是否只包含英文和數字 '************************************* Function IsvalidValue(ArrayN, Str) IsvalidValue = False Dim GName For Each GName in ArrayN If Str = GName Then IsvalidValue = True Exit For End If Next End
Time of Update: 2018-12-08
'************************************* '讀取檔案 '************************************* Function LoadFromFile(ByVal File) Dim objStream Dim RText RText = Array(0, "") Set objStream = Server.CreateObject("ADODB.Stream") With objStream .Type = 2 .Mode = 3
Time of Update: 2018-12-08
Function closeUBB(strContent) '************************************* '自動閉合UBB '************************************* Dim arrTags, i, OpenPos, ClosePos, re, strMatchs, j, Match Set re = New RegExp '申明re對象 re.IgnoreCase = True '設定是否區分字元大小寫 re.Global =
Time of Update: 2018-12-08
1、為圖片加入浮水印功能 Dim Jpeg Set Jpeg = Server.CreateObject("Persits.Jpeg") ' 建立對象 Jpeg.Open BlogPath & "/upload/" & FileName ' 圖片所在位置 Jpeg.Canvas.Font.Color = &H000000 ' 顏色,這裡是設定成:黑 Jpeg.Canvas.Font.Family = "方正隸變簡體" ' 設定字型
Time of Update: 2018-12-08
<script language="javascript" type="text/javascript"> //科目資料初始化 var subcat = new Array(); subcat[0] = new Array('0', '請選擇科目', '0'); subcat[1] = new Array('x1', '語文', 'x1yw'); subcat[2] = new Array('x2', '語文', 'x2yw'); subcat[3] = new Array('x3'
Time of Update: 2018-12-08
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "click", "alert('刪除成功"+queryId+"')", true);解決 asp.net onClientClick 與 驗證控制項衝突問題<script type="text/javascript"> function checkSubmit(){ Page_ClientValidate(); //內建函數 return
Time of Update: 2018-12-08
下面我們將要介紹另一種在ASP裡防SQL注入攻擊的方法,該方法不僅僅在ASP裡適用,實際上可以在任何使用ADO物件模型與資料庫互動的語言中,準確的說稱之為基於ADO物件模型的防SQL注入的方法或許更恰當些。好了廢話不說了,來看看代碼複製代碼 代碼如下:Dim conn,cmd,pra set conn=server.createobject("adodb.connection") conn.Open "…………" '這裡省略資料庫連接字 set cmd=server.createobject("
Time of Update: 2018-12-08
它的原理是:asp.net頁面提交的時候會調用ValidatorOnSubmit方法(內建的),我們利用js方法的覆蓋特性,把系統內建的ValidatorOnSubmit替換成我們的版本,然後當執行ValidatorOnSubmit時屏蔽掉頁面上所有提交按鈕(也可以執行你自己的方法) //屏蔽所有提交按鈕 function disableOtherSubmit() { var obj = event.srcElement; var objs =
Time of Update: 2018-12-08
con.close() 是關閉串連,實際上是把串連放回ado.net的串連池,並沒有真正關閉,所以再次串連時只是把串連從池中拿出來用,速度很快。 con.dispose是用來釋放對象的所在記憶體,相對於new sqlconnection(); 只用dispose是不能關閉connection的,兩者不是一回事,只用close也不能釋放它所佔的記憶體。 conn.dispose() 是銷毀串連,徹底關閉。
Time of Update: 2018-12-08
在DataGrid控制項中添加超連結如下步驟: (1) 在"設計"視圖中,選擇DataGrid控制項,然後單擊"屬性"視窗底部的"屬性產生器"連結。 (2) 在"DataGrid屬性"對話方塊中單擊"列"選項卡。 (3) 在"可用列"選項框中,選擇"超級連結列"並單擊"添加"按鈕。如進行添加超級連結列的設定。(4) 若要將資料欄位用作目標頁URL的源,請從"URL欄位"文字框中填寫該欄位名。在這種情況上,可以使用 "URL 格式字串"選項框為該超級連結文本指定格式設定運算式。
Time of Update: 2018-12-08
例如: protected void Page_Load(object sender, EventArgs e) { //.net1.1 Button1.Attributes.Add("onclick", "this.disabled=true;" + this.GetPostBackEventReference(this.Button1)); //.net 2.0以上 Button1.Attributes.Add("onclick", "this.disabled=true;" + this.
Time of Update: 2018-12-08
好多時候,資料庫查詢統計時需要使用本周統計 這裡又不想把計算的任務交給資料去做 於是自己寫個小函數,得到本周的周一和周末的時間,資料庫比較的時候只需要 between ... and 就可以了 代碼如下: #region 得到一周的周一和周日的日期 /// <summary> /// 計算本周的周一日期 /// </summary> /// <returns></returns> public static DateTime
Time of Update: 2018-12-08
當地址欄沒有參數"id"時: 複製代碼 代碼如下:Request.QueryString["ID"] == null Convert.ToString(Request.QueryString["ID"]) == null 注意這樣會出錯: Request.QueryString["ID"].ToString(); 當地址欄有參數"id",但沒有賦值的時候: 複製代碼 代碼如下:Request.QueryString["ID"] == ""
Time of Update: 2018-12-08
#region 得到一個月的第一天和最後一天的日期 /// <summary> /// 得到本月的第一天日期 /// </summary> /// <returns>DateTime</returns> public static DateTime GetFirstDayOfMonth() { return GetFirstDayOfMonth(DateTime.Now); } /// <summary> ///
Time of Update: 2018-12-08
大檔案上傳控制項(包含進度條) 使用說明如下: <summary> 上傳進度條控制項 </summary> <example> Web.config 配置 <?xml version="1.0"?> <configuration> <configSections> <!--上傳節點--> <sectionGroup
Time of Update: 2018-12-08
<br style='mso-data-placement:same-cell;'/> 完整代碼: 複製代碼 代碼如下:<%@ Page Language="C#" Trace="false" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
Time of Update: 2018-12-08
一、Transfer Execute Redirect重新導向方法介紹 1.Server.Transfer方法: Server.Transfer("m2.aspx");//頁面轉向(伺服器上執行)。伺服器停止解析本頁,儲存此頁轉向前的資料後,再使頁面轉向到m2.aspx, 並將轉向前資料加上m2.aspx頁結果返回給瀏覽器。 2.Server.Execute方法: Server.Execute("m2.aspx"); 伺服器儲存此頁轉向前的資料後,使頁面轉向到m2.aspx執行,
Time of Update: 2018-12-08
複製代碼 代碼如下:public DataSet createCache() { //返回DataSet DataSet ds=new DataSet(); OleDbConnection conn=new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source="+Server.MapPath("data.mdb")); conn.Open(); string sql="select * from data1 order
Time of Update: 2018-12-08
在web.config中: 複製代碼 代碼如下:<connectionStrings> <add name="SqlServices" connectionString="server=.;database=data;uid=sa;pwd=123;" /> </connectionStrings>複製代碼 代碼如下:<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15"&
Time of Update: 2018-12-08
下面,我們就分別介紹如何通過Web Services從伺服器下載檔案到用戶端和從用戶端通過Web Services上傳檔案到伺服器。一:通過Web Services顯示和下載檔案 我們這裡建立的Web