Time of Update: 2017-02-28
具體實現: 1,添加SingleSingOn.cs(這個cs檔案可以網上下載,然後SSOHost更改為自己的地址) 2,Controller中添加Login方法: SingleSingOn sso = new SingleSingOn();//
Time of Update: 2017-02-28
這篇文章主要介紹了asp.net錯誤頁面處理樣本,需要的朋友可以參考下1.建立Golbal.asax 代碼如下:void Application_Error(object sender, EventArgs e) { Exception objErr = Server.GetLastError().GetBaseException(); string error = "發生異常頁: " +
Time of Update: 2017-02-28
這篇文章主要介紹了asp.net + ajax + sqlserver 自動補全功能,需要的朋友可以參考下代碼下載 說明:資料庫連接字串在web.config檔案中,為方便運行使用的是官方的Northwind資料庫。 參考(向其作者致敬): ²
Time of Update: 2017-02-28
這篇文章主要介紹了asp.net讀取excel檔案的三種方法樣本,包括採用OleDB讀取Excel檔案、引用的com組件讀取Excel檔案、用檔案流讀取,需要的朋友可以參考下方法一:採用OleDB讀取Excel檔案 把Excel檔案當做一個資料來源來進行資料的讀取操作,執行個體如下: 代碼如下:public DataSet ExcelToDS(string Path) { string strConn =
Time of Update: 2017-02-28
這篇文章主要介紹了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
Time of Update: 2017-02-28
這篇文章主要介紹了asp.net操作xml增刪改樣本,需要的朋友可以參考下 代碼如下:using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using
Time of Update: 2017-02-28
ASP.NET依託.net framework類庫,封裝了大量的功能,使得上傳檔案非常簡單,主要有以下三種基本方法,需要的朋友可以參考下方法一:用Web控制項FileUpload,上傳到網站根目錄。 Test.aspx關鍵代碼: 代碼如下:<form id="form1" runat="server"><asp:FileUpload ID="FileUpload1"
Time of Update: 2017-02-28
這篇文章主要介紹了asp.net匯出excel的簡單方法執行個體,需要的朋友可以參考下excel的操作,最常用的就是匯出和匯入,廢話不多說上代碼。 本例使用NPOI實現的,不喜勿噴哈。。。。 代碼如下:/// <summary> /// 匯出Excel /// </summary>
Time of Update: 2017-02-28
這篇文章主要介紹了asp.net 備份和恢複資料庫的方法樣本,需要的朋友可以參考下 代碼如下:/********************************************************************************** * * 功能說明:備份和恢複SQL Server資料庫 * 作者: 劉功勳; * 版本:V0.1(C#2.0);時間:2007-1-1 *
Time of Update: 2017-02-28
這篇文章主要介紹了asp.net實現線上音樂播放器樣本,需要的朋友可以參考下 代碼如下:<HTML> <HEAD><TITLE>Playback Example</TITLE> </HEAD> <BODY> <script
Time of Update: 2017-02-28
這篇文章主要介紹了asp.net datalist綁定資料後可以上移下移的範例程式碼,需要的朋友可以參考下 代碼如下:if (e.CommandName == "Up") { int index = e.Item.ItemIndex; string TitleID =
Time of Update: 2017-02-28
這篇文章主要介紹了asp.net怎麼擷取HTML表單File中的路徑,需要的朋友可以參考下 代碼如下:#region 上傳檔案到資料庫和伺服器 public void FN_UpFiles() { //遍曆File表單元素 HttpFileCollection files = HttpContext.Current.Request.Files; try { for (int iFile = 0;
Time of Update: 2017-02-28
這篇文章主要介紹了asp.net發送郵件樣本分享,需要的朋友可以參考下mailhelper -------mail協助類 代碼如下:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mail; /// <summary>///mailhelper 的摘要說明///
Time of Update: 2017-02-28
這篇文章主要介紹了用ASP.net判斷上傳檔案類型的三種方法,需要的朋友可以參考下一、安全性比較低,把文字檔1.txt改成1.jpg照樣可以上傳,但其實現方法容易理解,實現也簡單,所以網上很多還是採取這種方法。 代碼如下:Boolean fileOk = false; string path = Server.MapPath("~/images/"); //判斷是否已經選取檔案 if
Time of Update: 2017-02-28
這篇文章介紹了ASP.NET動態設定頁面標題的方法詳解,有需要的朋友可以參考一下 ASP.NET為我們提供了一個控制項類:System.Web.UI.HtmlControls.HtmlGenericControl。它可以實現 HTML的元素的一個執行個體,比如在.cs代碼中控制aspx中的<td>元素(注意,它不是<ASP:TableCell>)。 我們知道,頁面標題是被包含在<TITLE></TITLE>中的,而<
Time of Update: 2017-02-28
這篇文章介紹了Asp.net圖片上傳實現預覽效果的簡單代碼,有需要的朋友可以參考一下 在頁面上放入一個上傳控制項和一個圖片控制項.複製代碼 代碼如下: <asp:FileUpload ID="FileUpload1" runat="server" onpropertychange="show(this.value)"/>
Time of Update: 2017-02-28
在ASP.NET中,如果你使用了URL重寫,通過HttpContext.Request擷取到的是重寫後的地址。如果這個地址要返回給用戶端(比如Redirect),我們一般希望是重寫前的友好地址。 通常的使用情境是當我們有某個頁面需要使用者登入才能訪問時,我們會在代碼中判斷當前訪問使用者是否登入,如果未登入,則重新導向至登入頁面,並將當 前網址通過Url參數傳遞給登入頁面。如果使用了URL重寫,並通過Request.Url.AbsoluteUri擷取當前網址,使用者登入後開啟的就是
Time of Update: 2017-02-28
這篇文章介紹了Asp.Net擷取網站截圖的執行個體代碼,有需要的朋友可以參考一下 複製代碼 代碼如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1{&
Time of Update: 2017-02-28
這篇文章介紹了asp.net StreamReader 建立檔案的執行個體代碼,有需要的朋友可以參考一下 複製代碼 代碼如下:using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using
Time of Update: 2017-02-28
這篇文章介紹了ASP.Net擷取用戶端網卡MAC的小例子,有需要的朋友可以參考一下 複製代碼 代碼如下:using System.Text.RegularExpressions;using System.Diagnostics;public class test{ public test