Time of Update: 2017-01-19
1. 頁面 在onclick事件中 "傳自己" 複製代碼 代碼如下: <asp:TemplateField HeaderText="全選"> <HeaderTemplate> <input type="checkbox" id="CheckBox1" name="CheckBox1" onclick="GetAllCheckBox(this)" /> 全選 </HeaderTemplate> <ItemTemplate>
Time of Update: 2017-01-19
在a.aspx跳轉到b.aspx 通過Server.Transfer("b.aspx") 與Response.Redirect("b.aspx")的區別 如果是通過通過Server.Transfer()在a.aspx跳轉到b.aspx的,則在b.aspx頁面,可以尋找到儲存在a.aspx頁面中的 控制項中的值,如果是Response.Redirect(),則得不到到a.aspx頁面中控制項的值。 如果是通過Server.Transfer("b.aspx"),則可以通知以下方式得到 保留在
Time of Update: 2017-01-19
複製代碼 代碼如下: public void FileDownLoadDel(string fullFilename) { System.IO.Stream iStream = null; // Buffer to read 10K bytes in chunk: byte[] buffer = new Byte[10000]; // Length of the file: int length; // Total bytes to read: long dataToRead; //
Time of Update: 2017-01-19
實現代碼如下: 複製代碼 代碼如下:using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using
Time of Update: 2017-01-19
複製代碼 代碼如下:/// <summary> /// 分頁連結 /// </summary> /// <param name="pageSize"></param> /// <param name="recordCount"></param> /// <param name="currentPage"></param> /// <param name="prev">當前頁前面顯示的數量&
Time of Update: 2017-01-19
加浮水印的功能代碼如下所示 複製代碼 代碼如下: /// <summary> /// 圖片修改類,主要是用來保護圖片著作權的,著作權歸原作者所有 /// </summary> public class picmark { #region "member fields" private string modifyImagePath = null; private string drawedImagePath = null; private int rightSpace;
Time of Update: 2017-01-19
複製代碼 代碼如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="BLTZ.aspx.cs" Inherits="BLTZ" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script
Time of Update: 2017-01-19
首先添加命名空間 複製代碼 代碼如下: using System.Data.OleDb; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { strfile = Request.QueryString["filename"];//從其他頁面傳過來的檔案路徑 Excel(strfile); } } private void Excel(string filepath) { try { Dataset
Time of Update: 2017-01-19
複製代碼 代碼如下:public void listArticle() { CmsArticle arObj = new CmsArticle(); DataSet ds = arObj.listArticle(); if (ds != null) { PagedDataSource pds = new PagedDataSource(); pds.DataSource = ds.Tables[0].DefaultView; pds.AllowPaging = true;
Time of Update: 2017-01-19
但是問題來了,不同科系的同學的科目是不一樣的,那麼我們在資料庫設計的時候通常是把學生、某科成績作為一條記錄,那麼這個時候我們就需要做一個行轉列的邏輯處理了。 解決方案: 使用GridView來產生表單,這個實現起來會比較麻煩,如果要在列表裡面顯示連結就更不可能了; 產生html再輸出到頁面中,這個實現起來比較靈活、方便; 準系統點: 動態產生表頭; 資料進行分頁; 查詢資料; 對每個成績進行超連結,查看明細; 頁面代碼 複製代碼 代碼如下: <div id="dataDiv1"
Time of Update: 2017-01-19
1,在web網站中建立兩個resources檔案如下 Resources.resx中的檔案資訊Resources.en-us.resx中的檔案資訊Default.aspx的代碼複製代碼 代碼如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Culture="Auto" UICulture="Auto"%>
Time of Update: 2017-01-19
如果頁面單純的使用js來建立,要寫大量的代碼,而且不直觀。 在asp.net中,其實我們可以建立使用者自訂控制項,通過Ajax請求返回使用者自訂控制項HTML代碼。複製代碼 代碼如下:public static string RangerUsControl(string controlName) { StringBuilder build = new StringBuilder(); HtmlTextWriter htmlWriter = new HtmlTextWriter(new
Time of Update: 2017-01-19
就是希望讓Web應用程式從一開始運行到結束都一直存在,有人就說為什麼不用Application呢?其實Cache是可以一段時間內自動更新資料的,而Application就無法做成這樣的,另外Application在Web這種高並發的系統中一定要考慮安全執行緒的問題,Application本身就不是安全執行緒的,而Cache就是安全執行緒。所以一般我都會在很多個物件中我只從Web開始啟動並執行時候從資料庫或檔案裡擷取一次資料,在不同的頁面中,都是使用Cache的,而且Cache中的資料可能弄成自動
Time of Update: 2017-01-19
放在伺服器端,也可以用ajax來實現,不刷頁面。但我覺得有更直接更簡單方法,用一個js事件是可以實現的。 但,DropDownList不偈Button等控制項提供了一些像"OnClientClick"前台事件,只有服務端事件。 想到,所有C#頁面代碼,最終都是產生HTML,js事件也是最終運在瀏覽器中,以Html為基礎的。服務端控制項最終產生的HTML控制項有什麼js事件,我們應該就能在aspx中給它添加相應的事件。 DropDownList
Time of Update: 2017-01-19
1 顯示枚舉的值:<%# (CN80s.DDPM.Model.Enum.EnumBidCardStatus)(int)Eval("PerpaidCard_Status")%> 2 為下拉框綁定枚舉: 複製代碼 代碼如下: GetEnumList(ddlBids); void GetEnumList(DropDownList ddl) { foreach (EnumBidCardType s in
Time of Update: 2017-01-19
在微軟推出.NET並進行了大規模的推廣普及之後,ASP.NET逐漸進入了資訊化系統開發的主流。但與此同時,而用ASP開發的舊系統面則臨被整合,這時,面臨一個問題:ASP與ASP.NET互相整合時,其中文COOKIES資訊無法被互連共用,當使用ASP.NET寫入中文COOKIES資訊後,使用ASP進行讀取,讀出來的卻是亂碼,而非中文。 後來通過尋找資料,不停地實踐,終於找到了問題的根源,中文COOKIES資訊在ASP中無法被正確讀取得原因為其中文編碼格式不同。
Time of Update: 2017-01-19
核心技術: 複製代碼 代碼如下: using System.Data.SqlClient; using System.IO; string SqlStr1 = "Server=(local);DataBase=master;Uid=sa;Pwd="; string SqlStr2 = "Exec sp_helpdb"; string SqlStr1 = "Server=(local);database='" + this.DropDownList1.SelectedValue + "';Uid=
Time of Update: 2017-01-19
我還是直接貼例子在說明一下吧: 複製代碼 代碼如下: //Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using EncodeMy; namespace TestEnCode { public
Time of Update: 2017-01-19
假設現在主表為公司表(公司ID,公司名稱,公司類型,公司規模),從表為部門表(部門ID,公司ID,經理,聯絡電話),現在一個公司有四個部門,要在同一個頁面上錄入公司資訊以及四個部門的資訊,如何動態建立部門資訊錄入口,以及如何擷取資料存放區到資料庫中,請看下面的代碼。 頁面HTML代碼及js指令碼 代碼 複製代碼 代碼如下: <%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits=
Time of Update: 2017-01-19
1、靜態模板頁面 template.html,主要是定義了一些特殊字元,用來被替換。 複製代碼 代碼如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;