MAIN MENU
News Php Tips Android Programming Design Pattern By PHP Linux Quick Tips C# using Linq น่าใช้จริงๆ C# Tips & Technique Java & JavaScript Tips Database ZengCode Framework Guide Zeng Code Code Programming IPhone (Tips and Trick)
|
|

สวัสดีครับแฟนๆ Madoogun.com ยินดีต้อนรับสู่บ้านใหม่ครับ
ZengCode framework ขอฝากเนื้อฝากตัวกับชาว Developer ทุกท่านด้วยนะครับ
ผู้พัฒนาเองไม่ได้หวังว่ามันจะใช้งานได้ดีขนาดไปเทียบกับจ้างยุทธจักรด้านนี้
ไม่ว่าจะเป็น Prado หรือแม้แต่ Cake ซึ่งนั้นเค้าระดับเทพเรียกพี่แล้วครับ
ผมก็เป็นแค่ Developer ธรรมดา ๆ คนนึงครับ
ที่สร้าง framework ตัวนี้ขึ้นมาก็เพื่อศึกษา และพัฒนาทักษะด้าน OOP ของตัวเอง
อีกทั้งปกติตัวผมเองเขียนโค้ดได้มั่วซั่วมาก ไม่มีระเบียบ อยากเขียนอะไรคิดออกก็เขียน
ไม่มีแบบแผน บางทีกลับมาแก้โค้ดตัวเอง บอกได้คำเดียวว่า เซ็งโครต เซ็ง โครต โครต
และนี่จึงเป็นที่มาของชื่อ framework ของผมครับ
และอีกประเด็นก็เพื่อจุดประการให้พี่น้องชาว Developer ทุกท่าน
ช่วยกันคิดพัฒนาสิ่งต่างๆ เพื่อวงการด้าน IT
ของเราได้ทัดเทียมนานาอารยะประเทศเค้านะคร ับผมขอเป็นจุดเล็กๆจุดนึงที่พร้อมจะมุ่งมั่น
พัฒนาผลงานด้านนี้ต่อไปครับ สู้ๆ นะพี่น้องชาว Developer ทุกท่าน
งานรับปริญา คลิกดูรูป

|
บทความล่าสุด
Diffirence แถว ระหว่าง Text File (2010-03-10)
เปรียบเทียเอาค่าที่มีใน Text File1 ที่ไม่มีใน Text File 2 ไม่ต้อง loop เทียบแล้วครับ
// Create the IEnumerable data sources.
string[] list1 = System.IO.File.ReadAllLines(@"c:/test/list1.txt");
string[] list2 = System.IO.File.ReadAllLines(@"c:/test/list2.txt");
// หาแถวที่มีใน list1 แต่ไม่อยู่ใน list2
IEnumerable<string> differenceQuery = list1.Except(list2);
// loop ค่ามาแสดงใน rich Text
foreach (string str in differenceQuery)
richTextBox1.AppendText(str+"\n"); |
อ่านต่อคลิกที่นี้
|
การอ้างถึง Control ที่อยู่ใน Master Page (2010-03-04)
พอดีน้องที่ทำงานมีเรื่องชวนให้ปวดหัว ถามคำถามนี้ขึ้นมาว่า จะอ้างถึง Control ใน Master Page ยังไง
เอาหล่ะซิ่ ไม่เคยทำซะด้วยก็เลยช่วยกันหา ได้คำตอบประมาณนี้ครับ
อันแรกนี่เป็น หน้า HTML Code ของ Master File นะครับ
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="WebApplication1.Site1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
|
อ่านต่อคลิกที่นี้
|
C# สร้าง Object ตอน Runtime โดยการระบุ ชื่อ Class และ Method (2010-03-04)
บางครั้งเราต้องการที่จะสร้าง Class ตอน Runtime โดยการระบุ เฉพาะชื่อ และ method ที่ต้องการจะเรียกตอน Runtime
ผมลองผิดลองถูกอยู่หลายวิธี อันนี้แหระครับเด็ดสุดแล้ว หรือใครมีเด็ดๆ ก็แนะนำกันมานะครับ ผมก็เพิ่งเขียน C# จริงจังไม่กี่เดือนเองครับ
ผมได้เขียนตัวอย่างการเรียกโดยใช้ Reflection ใน C# นะครับ พร้อมกันนี้ผมก็เขียน Class ที่มีการ Override Method จาก Class แม่
ซึ่งระบะ keyword virtual ไว้ (Polymophism) ยิงปืนนัดเดียวได้นกสองตัว
อันแรกเป็นคลาส Animal , Dog และ Cat ที่มีการทำ Override นะครับ
class Animal
{
public virtual String Say(String myname)
{
return "I am the animal!!!!" + "\n My name is " + myname;
}
}
class Dog : Animal
{
public override string Say(String myname)
{
return "I am a dog and " + base.Say(myname);
}
}
class Cat : Animal
{
public override string Say(String myname)
{
return "I am a cat and " + base.Say(myname);
}
} |
อ่านต่อคลิกที่นี้
|
ใครว่าใน ASP.NET ด้วย C# สร้าง control ตอน runtime ไม่ได้ (2010-03-03)
ใครว่าใน ASP.NET ด้วย C# สร้าง control ตอน runtime ไม่ได้ อ่ะทำให้ดู ก็ทุกอย่างมันเป็น Oject นี่ครับ อย่าเถียง
ไปศึกษา OO มาอีกนิดนะ หุหุ
ส่วนที่แรกเป็นส่วน ของ MyButton.cs นะครับ (เป็นคลาส ฺButton ที่ inherite มาจาก คลาส Button)
|
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;
namespace ZengCodeNet
{
public class ZCBtn : Button
{
//จะ implement อะไรต่อก็ทำไปสุดแต่ใจจะปราถนาครับ ไม่ว่าจะเป็ฯ property หรือ method ต่างๆ
}
}
|
อ่านต่อคลิกที่นี้
|
C# มาลองใช้ Class Dictionary กันครับ (2010-03-02)
Dictionary/StringDictionary เป็น Collection ที่ใช้ในการรวบรวมข้อมูลของ name/value ที่มีความใกล้เคียงกัน ( โดย name/value จะคือค่า key และ item ของออบเจกต์ ) โดยออบเจกต์นี้จะคล้ายกับการใช้งาน Array เพียงแต่มีการใช้งานที่ง่าย และไม่มีฟังก์ชั่นซับซ้อนเท่า Array แต่ก็ใช้งานได้ในวงจำกัด
อันแรกนี่ Bean Class นะครับ
using System;
using System.Collections.Generic;
using System.Text;
namespace TestProgram
{
class Student
{
public string id { get; set; }
public string name { get; set; }
}
} |
อ่านต่อคลิกที่นี้
|
C# consume Oil Price จาก PTT โดยไม่ผ่าน WS Proxy ครับ (2010-02-26)
ไม่มีการ Add Web Refference (Web Service Proxy) จะใช้ HttpRequest และ HttpResponse นะครับ
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Xml;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//com.pttplc.www.PTTInfo a = new WindowsFormsApplication1.com.pttplc.www.PTTInfo();
//MessageBox.Show(a.GetOilPrice("thai",25,02,2553));
}
private void button2_Click(object sender, EventArgs e)
{
// String strSoapMessage = "<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><HelloWorld xmlns='http://tempuri.org/' /></soap:Body></soap:Envelope>";
String strSoapMessage = "<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><GetOilPrice xmlns='http://www.pttplc.com/ptt_webservice/'><Language>string</Language><DD>26</DD><MM>02</MM><YYYY>2553</YYYY></GetOilPrice></soap:Body></soap:Envelope>";
...............................................
|
อ่านต่อคลิกที่นี้
|
C# Soap Client โดยไม่ผ่าน WS Proxy (2010-02-25)
ที่ทำเช่นนี้ก็เพื่อนจะสามารถระบุ Web service และเรียก Method ได้ตอน runtime ไม่ต้องผ่าน Proxy นะครับ
String strSoapMessage = "<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><HelloWorld xmlns='http://tempuri.org/' /></soap:Body></soap:Envelope>";
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://localhost:3421/Service1.asmx/HelloWorld");
webRequest.Headers.Add("SOAPAction", "http://localhost:3421/Service1.asmx/HelloWorld");
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
StreamWriter stm = new StreamWriter(webRequest.GetRequestStream(), Encoding.UTF8);
stm.Write(strSoapMessage);
stm.Flush();
stm.Close();
IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
//รอจนกว่าจะตอบกลับ
asyncResult.AsyncWaitHandle.WaitOne();
// get the response
string soapResult;
using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
{
soapResult = rd.ReadToEnd();
}
MessageBox.Show(soapResult); |
ที่ผมต้องทำอย่างนี้ก็เพราะว่าผมต้องเรียก webservice จากข้างใน DLL อ่ะครับ
อ่านต่อคลิกที่นี้
|
Run only 1 instance of program. (2010-02-19)
พอดีน้องที่ทำงานถามว่าทำยังไง ผมใช้วิธีนี้ครับ ใครใช้วิธีอื่นที่ดีกว่านี้ก็โพสบอกกันบ้างนะครับ
bool mutexCreated = false;
System.Threading.Mutex mutex = new System.Threading.Mutex(true, "ZengcodeProgram", out mutexCreated);
if (!mutexCreated)
{
MessageBox.Show("Another instance is already running.");
System.Diagnostics.Process.GetCurrentProcess().Kill();
Close();
}
อ่านต่อคลิกที่นี้
|
c# เรียก web หรือ webservice ผ่าน SSL ครับ (2010-02-18)
หลังจากที่ลองมาร้อยแปดวิธี วิธีนี้ใช้งานได้ แต่ไม่แน่ใจว่าทำงานได้จริงหรือเปล่า ถ้าใครมีวิธีดีๆ ก็ แนะนำมานะครับ
ผมลองวิธีนี้แล้วโอเค แต่ยังไม่ได้ลองกับ webservice ครับผม
|
using System.Security.Cryptography.X509Certificates;
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(GetSSLPage("https://www.zengcode.com"));
}
|
อ่านต่อคลิกที่นี้
|
|
|