May 27, 2005

Developing Windows CE Applications

I was kind a busy with some windows ce applications for one of our clients. basically its a Pocket PC device with CSV file reader/writer & some data mining stuff. In this post im not going to tell about my project but i'd like to share some of the similiraties/differences with the .Net Compact Framework vs .Net framework. The .net compact framework has more in common with the full .net framework than it has differences. Both uses the Assemblies , both access portable executable files(PE) which contains the MSIL & metadata that defines the .net application. Compact Framework supports the Multithreaded programing model just likes the .net framework. Design /Develop Windows CE UI has never been easier. Unlike .Net Windows applications, we have to worry about the device we're targeting on & the processor type(for deployment CAB files). Compact Frmework Controls has less features than the .Net windows application. For example if we look at the WinCE Datagrid its really poor compare to .Net windows Grid. Anyhow its fun to work with Windows CE.

May 12, 2005

ASP.Net Cookie Handling

Recently i came across with a problem with HtttpCookies. I try to save the client information in a cookie. But i couldnt, so i was just trying to check whether cookie is enable or not in the client browser. I simply used Request.Browser.Cookies property. But it didnt gave me the result that i wanted. Then i realized Request.Browser.Cookies is for checking the Browser capability of handling cookies. I coudn't find anything which tells me browser cookies are enable or disable . So what i did was just simply tried to create a cookie & tried to read the value from it. Below u will find the code for the two pages i used to solved the problem. If you guys have better solutions than this pls let me know.

//Page 1
//Page Load Event

if(!IsPostBack)
{
if(Request.QueryString["AcceptCookies"] == null)
{
Response.Cookies["TestCookie"].Value = "ok";
Response.Cookies["TestCookie"].Expires = DateTime.Now.AddMinutes(1);
Response.Redirect("My2.aspx?redirect=" + Server.UrlEncode(Request.Url.ToString()));
}
else
{
//Can Redirect to the page You want
Response.Write(Request.QueryString["AcceptCookies"].ToString());
}
}


//Page2
//Page Load Event

string redirect = Request.QueryString["redirect"];
string acceptCookies = "";
if(Request.Cookies["TestCookie"] == null)
{
//No Cookies
acceptCookies = "0";
}
else
{
//Yes Cookies
acceptCookies = "1";
//Delete the Test Cookies
Response.Cookies["TestCookie"].Expires = DateTime.Now.AddMinutes(1);
}
Response.Redirect(redirect + "?AcceptCookies=" + acceptCookies );

May 10, 2005

Partial Classes

How many times we wished if we can work on the same class file while some other developer checkout the same file. Writing two methods by two developers on the same time on the same class file is barely impossible. But now its possible with Partial Classes(new C# Feature). You can split your class file into multiple files. check out the example below.


//partial class 1
public partial class Customer
{
private string _name;
private int _age;
}
//partial class 2
public partial class Customer
{
public string Name
{
get{return _name;}
set{_name = value;}
}
public int Age
{
get{return _age;}
set{_age= value;}
}
public void ShowMyName()
{
return Name;
}
}
public class MyBusiness
{
public void ShowCustomers()
{
Customer customer = new Customer();
customer.ShowMyName();
}
}

May 4, 2005

Generate properties automatically


I found this inresting article while i browse the net. its was good Add-in for VS to create get set for properties.
check it out
http://www.codeproject.com/macro/PropertyGenerator.asp

Stored procedure for Custom Paging


we already know that dataGrid control has built in paging feature. but there are some situation that we have to turn our mind to custom paging. Reason is that if we are binding 100000+ records to a DataSet we wont be showing al those records at once. If we use built in paging we are just binding the complete dataset to the datagrid at once. this will lead to a performance overhead becuase we have to bind the dataset al the time. what if we can pull out only the records we need & give options to the user to browse through the pages. All we have to do it write a StoredProcedure which returns required records. Check the out the Article beclow. you find it interesting i bet u do. Happy Programming!

Custom Paging with Stored Procedure


May 3, 2005

Datagrid with client side behavior

this one is really cool. i played with the sample code & applied to the sample project it was really nice. u should try this. Then you will get to know the capability of the DataGrid. trust me its really worth for you to read.

http://msdn.microsoft.com/msdnmag/issues/04/01/CuttingEdge/default.aspx

DataSets vs Collections

i still think there is a battle between those two. i heard there was some arguments going abt this in my office.. . anyhow i found some interesting artilce about this. worth to read so take ur time to read it.
http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/CustEntCls.asp

I personaly prefer working with collections. it's making my development easy. find out why.