MS .Net C# winform UI related tips:Increasing the width of label according to text width (winform Label wordwrap)

If you want Label to grow as its text grows:


(this will make your label to grow in width)
if you want text to get wrapped and your label to become, multiline automatically:

Label.MaximumSize = new Size(max_width_of_label, 0);

(in above label will grow but will not take care of other control, i mean it will not care about them, just try your self and see what happens)

You may also like to see:

Published in: on July 23, 2010 at 4:05 pm  Leave a Comment  
Tags: ,

ASP .Net 2003 : Error while trying to run project: Unable to start debugging on the web server. Server side-error occurred on sending debug HTTP request.(HTTP/1.1 500 Internal Server Error)

My friend copied his project from another machine to his machine, project was in asp .net 2003 fromat, which was working well in old machine. But when he tried to run it(for debugging purpose) from visual studio 2003 it gave following error :
Microsoft Development Environment
Error while trying to run project: Unable to start debugging on the web server. Server side-error occurred on sending debug HTTP request.
Make sure the server is operating correctly. Verify there are no syntax errors in web.config by doing a Debug.Start Without Debugging. You may also want to refer to the ASP.NET and ATL Server debugging topic in the online documentation.
OK   Help
Even we tried to run using url http:\\localhost\virtual_dir_name\page.aspx, but it was still giving error something like ‘HTTP/1.1 500 Internal Server Error’. Finally after searching over net we found following solution at
For us second solution worked. We did following step:
1.Deleted ASPNET windows user account (from control panel->User Accounts->Users Tab)
2.And then in command prompt(cmd, not vs command prompt) went to framework directory, i.e., in our case
C:\Windows\Microsoft.NET\Framework\v1.1.4322 and ran the command “aspnet_regiis -i” (to re-register the Framework 1.1 and reinstall ASPNET user).
And bingo !!! it worked without even restarting the machine/server.
Above solution solution also solved following problem.
We also faced the problem on creating new web project using 2003 on same machine, got the error:
Microsoft Development Environment
The Web server reported the following error when attempting to create or open the Web project located at the following URL: ‘http://localhost/WebApplication1’. ‘HTTP/1.1 500 Server Error’.
OK   Help


Published in: on June 2, 2010 at 10:07 am  Comments (2)  
Tags: ,

Some interesting read on Bit Twiddling: setting and resetting(clearing) bit

a | b…. a & c…….a^b…..~a*(a^b)…..

If above criptic notations make some sense for you and you enjoyed reading above then here is some resource for you. I was actually searching way to set or reset a bit on a number. Finally i got some solution to share:

Setting a bit:
number = number | (1 << n); //(it will set (n+1) th bit)

num1 = 32;//100000
n = 2;
num2 = num1 | (1<<n);//num2=36 (100100)…it is setting 3rd bit

Resetting(Clearing) a bit:
number = number & ~(1<<n); //it will clear (n+1)th bit.

num1 = 34; //100010
n = 1;
num2 = num1 & ~(1<<n); //num2=32(100000)…it is clearing 2nd bit

using above we can write function to set and reset bit:

/*set the bit at bitPos*/
int setBit(int num,int bitPos)
  return num | (1<<(bitPos-1));

and to clear:

/*reset(clear) the bit at bitPos*/
int resetBit(int num, int bitPos)
  return num & ~(1<<(bitPos-1));

Here I have found some good resource on bit twiddling:

Bit Twiddling Hacks

Some thing more advance:

Advanced bit manipulation-fu


1. Stack Overflow

introduction to interop: some good article from net

I was looking for some good tutorial on net for com interop, i got following nice articles:

Published in: on January 20, 2010 at 12:30 pm  Leave a Comment  
Tags: , , , ,

ExtJS Tips: How to check/unceck all the nodes of a tree(Ext.tree.TreePanel)

This post will help you to achieve following:

  1. Checking/Unchecking all the nodes of a tree.
  2. Checking/Unchecking all the childnodes of a node.
  3. Checking/Unchecking all the siblings of a node.(see comments..)

If you want to check/uncheck all the node of a tree or all the child node of a parent node then following is the way to acheive it:

//function to check/uncheck all the child node.
function toggleCheck(node,isCheck)
 var args=[isCheck];
//this will also affect the passed parentNode(node).

Now calling this function for checking/unchecking all the node of a tree:

<br />
var tree=//ext js tree.<br />
toggleCheck(tree.root,true);//for checking all the nodes<br />
//or<br />
toggleCheck(tree.root,false);//for unchecking all the nodes<br />

Now calling above function for checking/unchecking all the children of a node:

<br />
var parentNode=//a node from tree.<br />
toggleCheck(parentNode,true);//for checking all the child nodes<br />
//or<br />
toggleCheck(parentNode,false);//for unchecking all the child nodes<br />

If you find any error or face any difficulty please let me know by comments.

Published in: on January 18, 2010 at 11:22 am  Comments (18)  
Tags: , ,

WebDevelper tool: Browser size detection tool

Browser Size

This tool will give you idea about how many % of user are not able to see which part of your website.
This is develope by googler on his 20% time. If you want to see which part of page in your web site is used more/less this would do the job.

Read more about this tool from its developer:

Link to the tool is here:

Published in: on December 17, 2009 at 7:45 pm  Comments (1)  
Tags: , ,

ExtJS Error: invalid label error while using ScriptTagProxy for JSON data in Paging Grid Example

You can also read this post if you are getting above error while using ScriptTagProxy.

With little bit modification i was trying to use Paging Grid Example from ExtJS. And that where i was getting following error:

invalid label

Actually it was not filling my grid, while examining with firebug i got above error. After banging my head over internet i found the reason ;).
Actually it is using ScriptTagProxy to get json data from server. I was sending pure json from server which is not the correct way. ScriptTagProxy sends a url parameter called “callback” which is function name. You need to take this param and form a parameter call. For example callback=fun1 is comming from server, then what you need to do is enclose your json with fun1(yourJSON) call.
fun1({—-your json—-});

Following is an example of ASP.Net code for it:

 String json_string= //"some json here";
 String callback_function_name= Request.Params.Get("callback");
 String response_string = "";
 if (!String.IsNullOrEmpty(callback_function_name))
 response_string = callback_function_name + "(" + json_string + ")";
 response_string = json_string;

you can see the difference of data comming from server for Paging Grid Example. Open following two url:

After examining the data on your browser you will see that, first url is giving pure json, while second one is giving json enclosed in fun_1() function call. ScriptTagProxy is expecting the second data not the pure json one.

If you have any suggestions please feel free to comment.

Published in: on December 2, 2009 at 7:47 pm  Comments (6)  
Tags: , , ,

Sorting a number field in MySQL: Making order by work for number fields in mysql

When using Order By field having number doesnt work some time. Actually it tries to sort the fields considering them as string, so numbers 11,2,1,111,21,3 will be sorted like:
which is not desired, it should be:

To order the values as they should be, simply use the SQL ABS function.

to get this desired result use query like:

SELECT * FROM ‘myTable’ WHERE b=’abc’ ORDER BY ABS(price) ASC

here price is number field.

Published in: on November 18, 2009 at 11:36 am  Leave a Comment  
Tags: ,

Google Interview Questions: Interview by google…Do you need job in google?

Since lot of people do it, i also wanted to do this. misunderstand me
i am not talking about applying for a job at google, but i am going to write a post on it, i will try to add links to other pages from here, which will give an experiance about how it is to get interviewed by google ;).
If you know any other page where they have discussed about it please let me know throw comments. Also if you had any such experiance please let me know.

So here is various links to such pages:

Following link gives an idead about how to not get in google :). I think she did some mistake, yep she was nervous but quesioned asked was not so tough i guess…
My Nightmare Interviews With Google

This gives some typical question you would have heard about googles question:
15 Google Interview Questions That Will Make You Feel Stupid (GOOG)[]

Here is the real and good list of googles interview quesion:
140 Google Interview Questions[]

Here is set of another 15 questions, with answers 🙂
Answers to 15 More Google Interview Questions That Will Make You Feel Stupid[]

One more sad sotry 😦
Google Interview


A though with lot of comments..

Just a thought !!![]

A full story with lot of nice pics.
My Interview With Google

Another failure story but worth reading…
My interview experience with Google

Some thing from The Register
Tales from the Google interview room

Here is expriance of Peteris Krumins’ from his blog. Its really good. If you want to go for software engineer position it may help you.
Peteris Krumins’ Interview at Google

How To display table in GridView: Dynamically filling data in GridView from DataTable in ASP .Net

I had a datatable and i needed to show in a GridView in my ASP .Net page. Following is the code which help me to do so.

//get table to be shown in grid view;
DataTable dataTable = GetRequiredTable();
//assing table to the DataSource property of GridView
//bind data from a data source to the GridView control

Here GetRequiredTable() is a user(example) function which return a table to display in to gridview.
You can also use DataSet in place of DataTable.

Published in: on November 17, 2009 at 10:27 am  Leave a Comment  
Tags: , ,