Time of Update: 2017-01-19
伺服器控制項雖然用起來方便,但是也犧牲了效能,有些時候用起來顯得大而無當。希望先進朋友多多指教。複製代碼 代碼如下:/// <summary> /// 工程業績--用for迴圈代替了DataList多列顯示,得到2行四列的表格,需要記憶體表的8行資料 /// </summary> private void GcyjShow() { StringBuilder sb = new StringBuilder(); ProductBLL pb = new ProductBLL(
Time of Update: 2017-01-19
使用命令列工具aspnet_regiis.exe 你還能夠使用aspnet_regiis.exe命令列工具來加密和解密Web.config檔案配置部分,你可以在"%WINDOWSDIR%\Microsoft.Net\Framework\version"目錄下找到這個工具。為了加密Web.config檔案中的一個節,你可以在這個命令列工具中使用DPAPI機器密鑰,如下所示: 加密一個特定網站的Web.config檔案的通用形式: 複製代碼 代碼如下: aspnet_regiis.exe -
Time of Update: 2017-01-19
方法一: Home/Index.aspx中的代碼 複製代碼 代碼如下: <% using (Html.BeginForm("up","Home",FormMethod.Post,new{enctype="multipart/form-data"})) {%> <input type="file" name="upfile" /> <input type ="submit" name ="upload" value ="上傳" /> <%} %>
Time of Update: 2017-01-19
在網上搜了一下事件執行順序,並經過測試在有分頁的情況下是不正確的。事件執行順序: 一、GridView 顯示繫結資料(預設為5行): 複製代碼 代碼如下: DataBinding RowCreated:Header[0] RowDataBound RowCreated:DataRow[1] RowDataBound RowCreated:DataRow[2] RowDataBound RowCreated:DataRow[3] RowDataBound RowCreated:DataRow[4]
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
問題:大家都說使用 forms 驗證無法得到當前登入使用者除了使用者名稱之外的更多資訊,經過我的一番小實驗,在 forms 方式下內建的 userdata 可以為我們施展天地的地方。下面記錄一下我的操作步驟備忘。 step 1: web.config 配置關鍵地方: web.config配置 複製代碼 代碼如下: <!-- 通過 <authentication> 節可以配置 ASP.NET 用來 識別進入使用者的 安全身分識別驗證模式。 -->
Time of Update: 2017-01-19
前台代碼: 複製代碼 代碼如下: <asp:GridView ID="GridLog" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID" BorderColor="#333" BorderStyle="solid" BorderWidth="1" OnRowDeleting="PublicGridRowDeleting" GridLines="None" Width="98%"
Time of Update: 2017-01-19
複製代碼 代碼如下: 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 System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;
Time of Update: 2017-01-19
ASP.net 獲得用戶端的IP,最常見的是使用下述代碼: 複製代碼 代碼如下: string user_IP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; 對於瞭解Proxy 伺服器情況的人,我們會知道,如果使用者使用了Proxy 伺服器,上述代碼獲得的是Proxy 伺服器的IP地址;如果使用者使用了多個Proxy 伺服器,則是到達伺服器的最後一個Proxy 伺服器的IP地址。 REMOTE_
Time of Update: 2017-01-19
1. 添加CSS樣式: Style style = new Style(); style.ForeColor = System.Drawing.Color.Navy; style.BackColor = System.Drawing.Color.LightGray; this.Header.StyleSheet.CreateStyleRule(style, null, "body"); 2. 連結外部的CSS樣式表: HtmlLink link = new HtmlLink();
Time of Update: 2017-01-19
1、OWC11 這個控制項全稱是:Office Web Component 11,是office2003中的一個組件,可惜的是office2007中沒有了它的身影。不過安裝office2003之後可以引用,然後使用。使用過的人都知道,就是它的效果要差一點。 2、dotnetCharting http://www.dotnetcharting.com/ &
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
3種方法分別是: string a=""; 1.if(a=="") 2.if(a==String.Empty) 3.if(a.Length==0) 3種方法都是等效的,那麼究竟那一種方法效能最高呢?本人用實驗說明問題。 建立3個aspx頁面(為什麼用網頁,主要是利用Microsoft Application Center Test ) WebForm1.aspx 複製代碼 代碼如下: private void Page_Load(object sender, System.EventArgs
Time of Update: 2017-01-19
複製代碼 代碼如下:public string GetRandomColor() { Random RandomNum_First = new Random((int)DateTime.Now.Ticks); // 對於C#的隨機數,沒什麼好說的 System.Threading.Thread.Sleep(RandomNum_First.Next(50)); Random RandomNum_Sencond = new Random((int)DateTime.Now.Ticks); //
Time of Update: 2017-01-19
複製代碼 代碼如下: using System; using System.Data; using System.Configuration; 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;
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
1、 SQL注入攻擊的本質:讓用戶端傳遞過去的字串變成SQL語句,而且能夠被執行。 2、 每個程式員都必須肩負起防止SQL注入攻擊的責任。 說起防止SQL注入攻擊,感覺很鬱悶,這麼多年了大家一直在討論,也一直在爭論,可是到了現在似乎還是沒有定論。當不知道注入原理的時候會覺得很神奇,怎麼就被注入了呢?會覺得很難預防。但是當知道了注入原理之後預防不就是很簡單的事情了嗎? 第一次聽說SQL注入攻擊的時候還是在2004年(好像得知的比較晚),那是還是在寫asp呢。在一次寫代碼的時候,有同事問我,
Time of Update: 2017-01-19
Global.asax C# code 複製代碼 代碼如下: <%@ Application Language="C#" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Threading" %> <script runat="server"> string LogPath; Thread thread; void WriteLog() { while
Time of Update: 2017-01-19
解決方案如下(寫在公用模組裡,
Time of Update: 2017-01-19
//基本代碼設計 <div id="div-datagrid"> <asp:DataGrid id="DataGrid1" runat="server" CssClass="Grid" UseAccessibleHeader="True"> <AlternatingItemStyle CssClass="GridAltRow"></AlternatingItemStyle> <ItemStyle CssClass="GridRow">&