ASP.NET JavascriptSerializer for Array

I need to throw some database entry which are as simple as TIME, for this I got a string array in my ASP.NET code behind. I was throwing this String Array in JSON format after using JavascriptSerialize.Serialize method and it is making not so perfect Json script. I said it is not making perfect json because the expect result for me was something like this:


but it was returing something like


the difference is that it is converting the array in to string, however the ideal result can be


But we cannot change that functionality now, so what I realise we should use the eval function of javascript to make our Jquery or whatever JSON parse you are using. So my Jquery code looks like


success: function(data) {
var items = [];
$.each(data, function(ind, val) {
var myobject = eval(val);
$.each(myobject, function(i, v) {                   
items.push(‘<option value=”‘ + v + ‘”>’ + v+ ‘</option>’);

this convert the String to Javascript object using Eval function. Easy enough !!!

.NET C#.NET Operating System Programming

Read System TimeZone to DB

I was looking for the TimeZone Database which also need to told me if Given Timezone is DayLightSaving enabled or not. After searching few hours on Internet I found few database that do not tell the Daylight Saving stuff. Then I found a function in TimeZoneInfo class that list all System Timezone, I loop through it and got what I need.

using (SqlCommand sqlCmd = new SqlCommand(“”, Connection.MyConnection))
sqlCmd.CommandText = “Insert into tblTimezone (TimeZone, TimeZoneDifference, isDST) Values(@TimeZone, @TimeZoneDifference, @isDST)”;
sqlCmd.Connection = Connection.MyConnection;
foreach (TimeZoneInfo tzi in TimeZoneInfo.GetSystemTimeZones())
sqlCmd.Parameters.AddWithValue(“@TimeZone”, tzi.DisplayName);
sqlCmd.Parameters.AddWithValue(“@TimeZoneDifference”, tzi.BaseUtcOffset.ToString());
sqlCmd.Parameters.AddWithValue(“@isDST”, (tzi.SupportsDaylightSavingTime ? 1 : 0));

Keep it simple 🙂

.NET ASP.NET Blog: My thoughts C#.NET Joyous

Working Lot of new methodology

It is good to back as programmer. Loving my new phase of development career, I got involved in development of a online card game. After lot of thinking and reading, I decide to use some new technology and methodology which I have been hearing about a lot. I don’t dare to use them as I feel the kind of project we were doing lately are not big enough to learn and implement those concepts. After for this project it really become necessity to these technology rather than just a decision making. For example to build a game UI, I have three option GDI+, DirectX or WPF.. I have done GDI+ before and doesn’t feel it is best to make complex Graphical interface even for like of poker game. Though I use it to build Chess Interface, but I know how problematic it was. Second came in DirectX, the best but the complex solution. I need more time to learn it and project is getting delayed. Then I choose to learn and work on WPF which is relatively easier than DirectX.

It was really a nice decision to choose WPF. It is not only easier for me to learn as I already have some experience in HTML and web programming, but it give me control which is best suited for programmer of my culture. With no efforts I am now able to create a better looking UI. Ofcourse I didn’t test the UI on Windowx XP yet, but otherwise it looks great. I am not going to test it on Windows XP anyways as we don’t going to support it. Once I have the UI ready. I need to now communicate with Online database. So for this I already know the solution called as Web Services. But where will I found the Web Service in Visual Studio 2010 .. oh I think they rename it as WCF.. nope, they make a new concept altogether called WCF. Hmm.. with past experience of webservice I know that it was the perfect solution for me, but again WCF is almost similar no difference to code, so what harm it does to use it. Afterall it bring some new security measure and ease. So I again learn WCF and it took me 1 hr to cover the difference between Web Service and WCF and I am up and ready with my solution.

Making game UI is really so exciting that I am now looking for opportunity to upgrade my Chess game to WPF interface. Programming is really fun with those concept of programming and tools that I learn in recent past. It was complex then before in planning, but easy to implement. However the attitude of programmer is they need something ease to plan and implementation they are not bothered. I must suggest using WPF and WCF in your project where you need them. I haven’t try but they says WPF and Silverlight has same code or reusable. Well if that is the case then surely I will start giving Silverlight solution in next quarter or so.


OpenXML : New office file format

When I first heard that Microsoft change the file extension of MS Office Products and add “x” in them, I got surprised as that was not very common practise for me. But today when I word on that new file format, I really would say, it was a good move. Those who don’t know, Microsoft with Office 2007, has change the core of file format used by Office product, and with other office software getting popularity, they actually work on an Open File format/document format. This new file fomat is known as “office open XML” or OpenXML.

this file format is based on one idea, Create a XML of Data and formatting in file, zip it and save it. Simple and easy. This file format is not limted to MS Office, but understand it very well.

In my project I need to create an Excel file such that my user can generate a summary report in Excel fileformat on button click. All I need to do is add 10 more lines (Except data retrivel logic) in my software, include few library and I am done.

Thanks to which make my work easy, this is wrapper highlevel class based on Microsoft OpenXML Format SDK. which include some .NET assembly. This wrapper make it easy for you write Excel of Word document in few lines. A sample for ASP.NET is included from author, though I use it for Windows Application and it works like charm.


ZedGraph Unlocked

I was working on reporting application where I just need to create graphs and paste them on PDF file. For this I choose ZedGraph Control. It is perfect library I found. Although no new development is done on it lately. But they have nothing to code in it anyways.  They have good wiki and active forum to discuss. Anyways, previously when I use this library for same situtation i was not very sure how I use it only to create Graph file on disk. What I did was I use a Hidden Control on my Window Form application with its visibilty set to false. then I draw Graph on it and save the graph from that hidden form. Since it is a control I doesn’t know if there is any better way of doing it is available or not.

But today I thought to experiment a bit. I simply create a Class file in my application, import ZedLibrary in that class file. Create an object of ZedGraph Control within my class, Set all values that are set in my old application’s initilizecomponent function, and create disk graph as I do previously. And it works!!! i know this sound “obvious” thing to whom that know a control cannot be used without making its instance on form. But for those who are not very mature like me, they might not know this. Also, some controls are graphic bound (due to bad coding only). But seriously ZedControl is perfect in that manner.  

I learn a new thing today in .NET framework, that really tells why it is true object oriented and what we see on screen is only CODE at the end of day, so there is nothing to worries about the display if you can control it through property and methods.  

Now let me finish my project first :).

.NET ASP.NET Bookmarked C#.NET Links VB.NET/VB


Recently I finish a .NET 3.5 based desktop application, where I need to make graphs. For this I search few open source, ready to use library and with help of, I am able to find one such good library called ZEDGraph. However, it seems this project is no longer active, but it has a good reason that they might not have any new thing to add as it seems already full of features.

You can go to ZedGraph Wiki, or can ask question on its sourceforge forum which still is somewhat active and people are posting there.

This is really a good project and I will stick with it as I modify its source as well for one of very own custom requirement and hence I know its source architecture to us it in future as well.


Progress bar for long running ASP.NET scripts

Though I have posted in my old blog, but just to keep track of this..

This article suggest a method on how to show progress bar in your web application.