Time of Update: 2017-01-19
主要是Request.UrlReferrer的用法 注意: 如果上一頁面使用document.location方法導航到當前頁面,Request.UrlReferrer返回空值 如果有A,B兩個頁面,在瀏覽器中直接請求A頁面,在A頁面的中Page_Load事件中導航到B 頁面, 則 Request.UrlReferrer返回空。因為 在Page_load事件中頁面還未初始化,所以無法記錄當前頁的資訊, 導航到b頁面也就無法獲得上一頁面的資訊 複製代碼 代碼如下: protected void
Time of Update: 2017-01-19
直接上代碼: 複製代碼 代碼如下: using System; using System.Collections.Generic; using System.Text; using System.Reflection; using System.IO; using System.Net; using System.Xml; namespace Update { /// <summary>
Time of Update: 2017-01-19
整個程式的代碼如下: 複製代碼 代碼如下: using System; using System.Collections.Generic; using System.Text; using System.Web; using System.Web.UI; /// <summary> /// 彈出JavaScript小視窗 /// </summary> /// <param name="js">視窗資訊</param> public static
Time of Update: 2017-01-19
但是問題來了,不同科系的同學的科目是不一樣的,那麼我們在資料庫設計的時候通常是把學生、某科成績作為一條記錄,那麼這個時候我們就需要做一個行轉列的邏輯處理了。 解決方案: 使用GridView來產生表單,這個實現起來會比較麻煩,如果要在列表裡面顯示連結就更不可能了; 產生html再輸出到頁面中,這個實現起來比較靈活、方便; 準系統點: 動態產生表頭; 資料進行分頁; 查詢資料; 對每個成績進行超連結,查看明細; 頁面代碼 複製代碼 代碼如下: <div id="dataDiv1"
Time of Update: 2017-01-19
複製代碼 代碼如下://產生縮圖函數 //順序參數:源圖檔案流、縮圖存放地址、模版寬、模版高 //註:縮圖大小控制在模版地區內 public static void MakeSmallImg(System.IO.Stream fromFileStream, string fileSaveUrl, System.Double templateWidth, System.Double templateHeight) { //從檔案取得圖片對象,並使用流中嵌入的顏色管理資訊
Time of Update: 2017-01-19
加上之前學習過Linq to Entity,因此學習起來也比較隨心應手。 以下是項目中某個底層的代碼,記下做個備忘,如果能給新手學習Linq to Xml帶來協助,那就再好不過了 XML檔案的格式: 複製代碼 代碼如下: <?xml version="1.0" encoding="utf-8"?> <configuration> <OPsystemConfig> <MemberCenter>
Time of Update: 2017-01-19
如圖:點擊瀏覽,選擇圖片之後,右面顯示圖片第一步:建立CtFileUpLoad.ascx複製代碼 代碼如下: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="CtFileUpLoad.ascx.cs" Inherits="WebParts_CtFileUpLoad" %> <table cellpadding="0" cellspacing="0"> <tr> <td> <
Time of Update: 2017-01-19
aspx頁面代碼 複製代碼 代碼如下: <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> <script src="JQUERY.JS" type="text/javascript"></script> <style type="text/css"><!-- .hover {
Time of Update: 2017-01-19
複製代碼 代碼如下:DateTime dt = DateTime.Now; //本月第一天時間 DateTime dt_First = dt.AddDays(-(dt.Day) + 1); Label1.Text = dt_First.ToString("yyyy-MM-dd"); //將本月月數+1 DateTime dt2 = dt.AddMonths(1); //本月最後一天時間 DateTime dt_Last = dt2.AddDays(-(dt.Day)); Label2.Text
Time of Update: 2017-01-19
IIS收到請求-->ISAPI用於處理該請求-->BeginRequest開始-->EndRequest結束-->輸出Response 中間有好多其它的流程就不標記了,這裡只是列出URLRewrite所走的流程。 其實就是在BeginRequest事件中調用HttpContext的RewritePath方法,將該請求重新“定位”至一個目標URL就完成了。 在網站的Global.asax檔案BeginRequest方法中添加代碼: 複製代碼 代碼如下: public
Time of Update: 2017-01-19
項目我採用了三層結構,我把LINQ的對應檔放到了DAL這個層中,對應檔自動由VS2008產生,在原來的機器上一直正常,一點問題都沒有,當我把程式移到了另外一台機子上面時候,情況就發生了變化,怎麼都串連不上資料庫,這個問題折騰了我好幾天,改了DAL下的app.config,也改了Web下的web.config但是都沒有效果,一串連資料庫就報這個錯誤 Timeout expired
Time of Update: 2017-01-19
1,把代碼放在sqlhelper中。 複製代碼 代碼如下: #region 截取字串 /// <summary> /// 截取字串 /// </summary> /// <param name="str_value"></param> /// <param name="str_len"></param> /// <returns></returns> public static string
Time of Update: 2017-01-19
但是我在使用過程中,發現針對角色的控制並不是那麼容易,通過在網上尋找資料,終於解決這個問題。下面將主要的注意事項列出來。1、設定檔中,角色的allow項要放在deny項的前面,users要配置為*,而不是? 代碼 複製代碼 代碼如下: <location path="Doctors"> <system.web> <authorization> <allow roles="doctors"/> //這個在前 <deny
Time of Update: 2017-01-19
複製代碼 代碼如下:if (this.FileUpload1.PostedFile != null) { string filename = this.FileUpload1.FileName.ToString(); string path = @Server.MapPath("../File/") + filename; this.FileUpload1.PostedFile.SaveAs(path); //讀取使用者上傳的Excle檔案 string conn="Provider =
Time of Update: 2017-01-19
在ASP.NET包含檔案的方法有: 1.<% Response.WriteFile("skin/default/footer.txt")%> 2.<% server.execute("skin/default/footer.txt")%> 3.StreamReader 對象將包含檔案寫到 HTTP 內容流中 //me:網上說asp.net中用include也可以的。。 include和Server.Execute有什麼區別?
Time of Update: 2017-01-19
在Gridview 的 RowCreated事件中書寫如下代碼: 複製代碼 代碼如下: void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header) { //隱藏第1列 e.Row.Cells[0].Visible = false; //
Time of Update: 2017-01-19
1. 向項目添加app.config檔案: 右擊項目名稱,選擇“添加”→“添加建立項”,在出現的“添加新項”對話方塊中,選擇“添加應用程式設定檔”;如果項目以前沒有設定檔,則預設的檔案名稱為“app.config”,單擊“確定”。出現在設計器視圖中的app.config檔案為: <?xmlversion="1.0"encoding="utf-8" ?> <configuration> </configuration>
Time of Update: 2017-01-19
實現ASP.NET產生隨機密碼功能是很容易的,下面的代碼給出了完整的實現方法: 複製代碼 代碼如下: publicstaticstringMakePassword(stringpwdchars,intpwdlen) { stringtmpstr=""; intiRandNum; Randomrnd=newRandom(); for(inti=0; i{ iRandNum=rnd.Next(pwdchars.Length); tmpstr+=pwdchars[iRandNum]; }
Time of Update: 2017-01-19
1、直接在前台調用 javascript 函數 很簡單,在 head 元素之間加入 script 元素,將 type 元素設定為 " text/javascript " 如: 複製代碼 代碼如下: <head runat="server"> <script type="text/javascript" > function ShowName(str) { alert("您的名字為:("+str+")"); } </script>
Time of Update: 2017-01-19
使用者控制項代碼: 代碼WebControls 複製代碼 代碼如下: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace xuyuanwang.myControl { public partial class Lablexuyuan :