Wednesday, May 28, 2008

วิธีป้องกัน SQL Injection ใน ASP.Net

MSDN:How To: Protect From SQL Injection in ASP.NET

MSDN:How To: Protect From Injection Attacks in ASP.NET

MSDN:Anti-Cross Site Scripting

posted on Wednesday, May 28, 2008 10:52:52 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Wednesday, November 07, 2007
  1. Master page controls Init event.

  2. Content controls Init event.

  3. Master page Init event.

  4. Content page Init event.

  5. Content page Load event.

  6. Master page Load event.

  7. Content controls Load event.

  8. Content page PreRender event.

  9. Master page PreRender event.

  10. Master page controls PreRender event.

  11. Content controls PreRender event.

posted on Wednesday, November 07, 2007 7:40:28 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Monday, October 29, 2007

วิธีการใช้ Visual Studio สร้าง Data Access Layer ด้วย DataSet Designer ซึ่งง่ายและรวดเร็วในการสร้างสไตล์วิชวล ไม่ต้อง coding

http://www.theserverside.net/tt/articles/showarticle.tss?id=DataSetDesigner

 

posted on Monday, October 29, 2007 7:09:25 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]

เทคนิคการทำ Data Paging กับ Data List ของ Scott Gu

http://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx

 

posted on Monday, October 29, 2007 7:05:53 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Wednesday, October 24, 2007
โปรแกรมส่งค่า HTTP POST ด้วย C#
using System.Net;
...
string HttpPost (string uri, string parameters)
{ 
   // parameters: name1=value1&name2=value2    
   WebRequest webRequest = WebRequest.Create (uri);
   //string ProxyString = 
   //   System.Configuration.ConfigurationManager.AppSettings
   //   [GetConfigKey("proxy")];
   //webRequest.Proxy = new WebProxy (ProxyString, true);
   //Commenting out above required change to App.Config
   webRequest.ContentType = "application/x-www-form-urlencoded";
   webRequest.Method = "POST";
   byte[] bytes = Encoding.ASCII.GetBytes (parameters);
   Stream os = null;
   try
   { // send the Post
      webRequest.ContentLength = bytes.Length;   //Count bytes to send
      os = webRequest.GetRequestStream();
      os.Write (bytes, 0, bytes.Length);         //Send it
   }
   catch (WebException ex)
   {
      MessageBox.Show ( ex.Message, "HttpPost: Request error", 
         MessageBoxButtons.OK, MessageBoxIcon.Error );
   }
   finally
   {
      if (os != null)
      {
         os.Close();
      }
   }
 
   try
   { // get the response
      WebResponse webResponse = webRequest.GetResponse();
      if (webResponse == null) 
         { return null; }
      StreamReader sr = new StreamReader (webResponse.GetResponseStream());
      return sr.ReadToEnd ().Trim ();
   }
   catch (WebException ex)
   {
      MessageBox.Show ( ex.Message, "HttpPost: Response error", 
         MessageBoxButtons.OK, MessageBoxIcon.Error );
   }
   return null;
} // end HttpPost 
posted on Wednesday, October 24, 2007 7:25:05 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Thursday, September 06, 2007

แก้ไขปัญหา Focus บน ASP.Net 2.0

http://weblogs.asp.net/scottgu/archive/2005/08/04/421647.aspx

posted on Thursday, September 06, 2007 12:08:33 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Monday, June 11, 2007
 Wednesday, June 06, 2007

การ Shared Cookie ข้าม Web Applicaiton นั้นมีขั้นตอนดังนี้
1. แก้ไข Web.config โดยเพิ่ม <machinekey validationKey="xxx" descriptionKey="xxx" validation="xxx"> ให้เหมือนกัน
2. แก้ไข Web.config โดยกำหนดค่า <form name="xxx" path="/" protection="xx" /> ให้เหมือนกัน

Ref.
Technet : http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/3b69057f-39a7-4d0b-9315-ccc66a0c6676.mspx?mfr=true

MSDN : http://msdn2.microsoft.com/en-us/library/w8h3skw9.aspx

posted on Wednesday, June 06, 2007 7:33:11 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Saturday, June 02, 2007

การทำ Highligth ผลการค้นหา ด้วย C#
โดยวิธีแทนที่ keyword ด้วย <span> กับ CSS

http://dotnetjunkies.com/Tutorial/195E323C-78F3-4884-A5AA-3A1081AC3B35.dcik

posted on Saturday, June 02, 2007 5:11:04 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Friday, May 11, 2007

ไปดูกันได้ที่นี่ น่าสนใจมาก

http://msdn.microsoft.com/msdnmag/issues/05/01/ASPNETPerformance/default.aspx

posted on Friday, May 11, 2007 12:08:08 AM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Wednesday, May 09, 2007

ในที่สุด C# ก็สามารถสร้าง ActiveX Control ได้เหมือนกัน
ไปดูตัวอย่างได้ที่

http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx

posted on Wednesday, May 09, 2007 3:07:59 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Saturday, April 28, 2007

ให้แก้ไข Web.config ดังนี้

เก็บไว้ใน Event Viewer

<healthMonitoring>
<rules>
<add name="All Events" eventName="All Events" provider="EventLogProvider" profile="Critical"  />
</rules>
</healthMonitoring>

posted on Saturday, April 28, 2007 3:14:33 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]

Application: BeginRequest
Application: PreAuthenticateRequest
Application: AuthenticateRequest
Application: PostAuthenticateRequest
Application: PreAuthorizeRequest
Application: AuthorizeRequest
Application: PostAuthorizeRequest
Application: PreResolveRequestCache
Application: ResolveRequestCache
Application: PostResolveRequestCache
Application: PreMapRequestHandler
Page: Construct
Application: PostMapRequestHandler
Application: PreAcquireRequestState
Application: AcquireRequestState
Application: PostAcquireRequestState
Application: PreRequestHandlerExecute
Page: AddParsedSubObject
Page: CreateControlCollection
Page: AddedControl
Page: AddParsedSubObject
Page: AddedControl
Page: ResolveAdapter
Page: DeterminePostBackMode
Page: PreInit
Control: ResolveAdapter
Control: Init
Control: TrackViewState
Page: Init
Page: TrackViewState
Page: InitComplete
Page: LoadPageStateFromPersistenceMedium
Control: LoadViewState
Page: EnsureChildControls
Page: CreateChildControls
Page: PreLoad
Page: Load
Control: DataBind
Control: Load
Page: EnsureChildControls
Page: LoadComplete
Page: EnsureChildControls
Page: PreRender
Control: EnsureChildControls
Control: PreRender
Page: PreRenderComplete
Page: SaveViewState
Control: SaveViewState
Page: SaveViewState
Control: SaveViewState
Page: SavePageStateToPersistenceMedium
Page: SaveStateComplete
Page: CreateHtmlTextWriter
Page: RenderControl
Page: Render
Page: RenderChildren
Control: RenderControl
Page: VerifyRenderingInServerForm
Page: CreateHtmlTextWriter
Control: Unload
Control: Dispose
Page: Unload
Page: Dispose
Application: PostRequestHandlerExecute
Application: PreReleaseRequestState
Application: ReleaseRequestState
Application: PostReleaseRequestState
Application: PreUpdateRequestCache
Application: UpdateRequestCache
Application: PostUpdateRequestCache
Application: EndRequest
Application: PreSendRequestHeaders
Application: PreSendRequestContent

posted on Saturday, April 28, 2007 3:10:15 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Wednesday, April 25, 2007

ปกติ CSS Adapters นั้นจะใช้ได้ใน Template แบบ website ของ Visual Studio 2005 เท่านั้น
ไม่สามารถใช้ใน Web Application ได้

นี่คือวิธีการเปลี่ยน CSS Adapters ให้สามารถนำไปใช้ใน Web Application ได้

Copy the CSS Files
1.สร้าง sub directory ชื่อ Adapters  ใน folder styles จะเป็น
<siteroot>/Styles/Adapters/
2. copy file ทั้งหมดของ folder css ของ Control Adapter มาไว้
3. เพิ่ม <link ... /> เพื่อทำการ link css ในหน้า webpage

Copy the JavaScript Files
1. แก้ไข Web.config โดยเพิ่ม
<add key="CSSFriendly-JavaScript-Path" value="~/Scripts/Adapters/"/>
ซึ่งสามารถตั้งค่าได้ว่าจะให้เอา JavaScript ไปวางไว้ที่ folder อะไร

แค่นี้เป็นอันเสร็จ

posted on Wednesday, April 25, 2007 6:42:03 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Saturday, April 21, 2007
posted on Saturday, April 21, 2007 1:13:42 AM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Wednesday, November 29, 2006

ให้กำหนดค่าดังนี้ใน Page_Load แล้วจะมันจะไม่ส่งค่าไปเอง...อืม

Page.Form.SubmitDisabledControls = true ;

posted on Wednesday, November 29, 2006 12:00:13 AM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Monday, November 20, 2006

ใช้ตัวอย่าง code นี้ในการ export DataTalbe ไปเป็น Excel

public static void ExportToSpreadsheet(DataTable table, string name)

{

HttpContext context = HttpContext.Current;

context.Response.Clear();



foreach (DataColumn column in table.Columns)

{

context.Response.Write(column.ColumnName + ";");

}



context.Response.Write(Environment.NewLine);



foreach (DataRow row in table.Rows)

{

for (int i = 0; i < table.Columns.Count; i++)

{

context.Response.Write(row[i].ToString().Replace(";", string.Empty) + ";");

}

context.Response.Write(Environment.NewLine);

}



context.Response.ContentType = "text/csv";

context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + name + ".csv");

context.Response.End();

}

การเรียกใช้ด้วย

ExportToSpreadsheet(table, "products");

สามารถนำไปประยุกต์เป็น HTTP Handler เพื่อเรียกใช้ได้

posted on Monday, November 20, 2006 11:42:29 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Thursday, November 16, 2006

ไปอ่านวิธีการใช้ Java Script ใน ASP.Net 2.0 โดยเฉพาะวิธีการใช้ Page.ClientScript ซึ่งเปลี่ยนแปลงจาก ASP.Net 1.1

http://msdn2.microsoft.com/en-us/library/aa479390.aspx

posted on Thursday, November 16, 2006 5:45:16 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Tuesday, November 14, 2006
กำลังจะคุ้ยระบบ Security ของ ASP.Net 2.0
posted on Tuesday, November 14, 2006 12:15:48 PM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]
 Monday, November 13, 2006

คำสั่งในการสร้าง Table สำหรับ Membership ของ ASP.Net 2.0

C:\Windows\Microsoft .Net\Framework\v.2.0\aspnet_regsql.exe

posted on Monday, November 13, 2006 11:36:36 AM (SE Asia Standard Time, UTC+07:00)  #    Comments [0]