Thursday, October 11, 2007

Setting focus to control in Asp.NET 2

I'm building a website (as i told in my previous post). In one form i used wizard control. The problem was that the form is in master page, which itself contains navigation bar as header of the site. When page loaded, the control will go to links and controls on the master form first and then to controls in this form.

I googled and found nice snippets of Javascript and even a control class on codeproject. But I tried to go the easier way first. So in page_load event I tried like dropdownlist1.Focus() and voila it worked.

Next was to see on which step the wizard is, which I was already doing to validate the inputs from user, and set the focus to first control on next page of wizard.

There was a postback also, where a dropdown list changes and loads another one. In postback handler (dropdownlist2_selectedindexchanged) at the end, I wrote dropdownlist3.Focus() and it was working here too.

Hope it helps you.

Saturday, October 6, 2007

Another reason for "Failed to Update Database ..\App_Data\aspnet.mdf because database is readonly

I am currently working on ASP.NET 2 project. After working for 2 days and creating an outline for the site and flow for user interaction, I decided it was right time to put it into source control.

After I added it to source control it started giving me giving strange "database is read-only problem". I googled a bit about it. The solutions offered ranged from giving IIS process, ASPNET user and don't remember who else to give access to app_data folder. But it did not work.

Then there was an elaborate solution using command line sseutil . It recommended to detach the database and reattach it. After some futile attempts, I had to close VS, and restart Sql Express.

Again today some how I checked in all the files in solution and it again gave gave me same problem when I tried to create a Stored Procedure. Then occurred to me that maybe it is because the database file is checked in source control and is read-only (it was checked in). I detached it (with sseutil of course), checked out the file (aspnet.mdf) and it is working again alright.

Monday, August 27, 2007

Running Firebird Embeded Database in .NET 2

I wanted to create a small application to keep track of my daily expenses. Me and my friend (we are also room mates) think that we are expending too much because we are unstructured. So I thought to give it time this Sunday.

I decided to use embedded Firebird server for easy portability.

Go to Firebird site and it says that embedding Firebird is a breeze. Me to thought so. But it might be little cumbersome as many things have changed in Firebird version 2.
I downloaded Firebird embedded package. Copied fbembed.dll and Firebird.Data.FirebirdClient to my executable directory, but every time I tried to execute
FbConnection.CreateDatabase()
I got 'Unable to load DLL "fbembed"' error.

Googling for it yielded no results except advice for copying fbembed.dll and FirebirdClient assembly to the folder where executable is.

I copied everything from embedded package and it worked. But time and again it is mentioned that every thing from package is not needed. So now again I removed the embedded stuff and started things one-by-one.

  • First fbembed.dll and FirebirdClient assembly --> It did not work.


  • Then I added all the dlls (i*.dll) from embedded package with firebird.msg --> It did not work.<.li>
  • Then I added intl folder --> It worked!!!



No I coppied these files to bin folder and added the intl folder and the dlls to my .NET Project and set their build action as content and Copy to Output Directory as Copy Always.

It is working fine and I don't have to copy it to release or debug folders.

Happy Codding ;-)

Wednesday, August 8, 2007

Why Open Source Works

I'm studying Apache OFBiz for some time, because my company Vismaad is expecting a project in which we will be using it.
I ran into some problems and had to ask for help on ofbiz mailing list. It usually takes under 40 minutes to get an answer and if problem is not severe (means only you are doing something in wrong way) you can solve it in under 2 hours.
Great!!
Many commercial help desk services cannot give you this kind of support.
Now compare it to this:
I ran into a problem with ASP.NET 2.0 AJAX website when I was using CSS Adapters for controls. I posted my problem on official ASP forum. But even after many days I'm still to get any answer.
The myth that there is no money in open source is unfounded. You only need to look at the frantic activity in mailing lists and open source software forums. All those people are not doing the work only for hobby. Yes people are cooperative and guiding, but that does not means that they don't need money or make money. Many new features and changes get thoroughly discussed in these forums and lists. So it many users have problem configuring a feature or if something important is missing you can step in or request the follow users to have it fixed in next release or at least get a patch for it.
On the other hand if you look at closed source or propriety solutions you cannot force them to make any changes, and it they have some kind of monopoly or great market share (hey! don't make any guesses) it is impossible.
So moral of the story is that open up for opensource. See, Learn and if you like it use it and give back to community by promoting it, helping other in forums and mailing lists and contributing to source code.

Long Live Open Source

Why Open Source Works

I'm studying Apache OFBiz for some time, because my company Vismaad is expecting a project in which we will be using it.
I ran into some problems and had to ask for help on ofbiz mailing list. It usually takes under 40 minutes to get an answer and if problem is not severe (means only you are doing something in wrong way) you can solve it in under 2 hours.
Great!!

Many commercial help desk services cannot give you this kind of support. But still people relay on commercial services.

Tuesday, July 31, 2007

Where do I belong?

It is weekend and after 6 days of the rut you feel like unwinding a little. I like to describe here a little that our idea of unwinding is not as goes. We rented DVD of Sherek 3. It was 1 AM when the movie finished. After movie we went out for a little stroll.

Only 3-4 hundred meter from where we stay were some policemen. They stopped us and started asking about the identity prof. Now you don't carry your I-Cards, Driving Licenses, or passports with you, when you go for a stroll. So if you don't have ID prof then let someone from you higher ups talk to us. This is not the time of the day when you call up your boss and ask him to tell the policemen who you are.

The logic given by the cops for stopping us at that time was that there are all kind of people going around. But if we were such kind of people then we may have settled with somebody to be our "BOSS" to verify our antecedents.

So we asked them that if we really look like terrorists them we can walk up to our rooms and get our I-Cards. Somehow they believed in use and asked us to walk back because it was very late.

It really hurts when this type of thing happens with you in your own country. Where you are working and living since few years. I've been to abroad also but no body ever asked about my identity proofs at dead of the night when there is not even an emergency.
But you cannot argue with a cop and at that in middle of the night. Because if it hurts (not physically, just his ego) you can well be a terrorist by the morning or a hardcore criminal or a drug peddler. Because it is INDIA not Australia where police will say that they were at fault.

An amusing thing happened just when we were walking back. A car came from other side and our cops signaled them to stop. Most probably they were also coming after letting their hairs down. But they cheered and sped off.

Wednesday, July 25, 2007

Farewell to Kalam

Today Pratiba Patil is sworn in as 13th President. Hope she comes clear of all the muck that was raised on her in run up to the elections. The way we got out 13th president speaks of the nadir we our politicians have reached.

In the first place thinking of anybody else instead of Kalam as presidential candidate was treachery with the peoples and specifically youth's will. He is in very good health. He is well educated (really educated-not degree holder like many of the fools who run our country). He did lot for the country (he didn't even find time to get married because he was so busy making missiles to defend our country). He is truly secular. Mrs. Patil may serve well as a token of rise of women in India, but it never occurred to anybody that Kalam is Muslim. He is Indian and our president first.

His biggest contribution to the nation is the inspiration he imparted to the youth. His truthfulness, purity and intelligence always charmed the children and young people. He has visions about the future of country and its children.

I hope that Mrs. Patil will be able to stand up to the high office of the President of India. I wish Kalam a long and healthy life, so that he continues to inspire the youth and contribute to the development of India.

PS:- Let us see if BJP and allies win majority and Mr. Vajpayee does not swear in as PM, because he did not believe that same person should be given second term in Rashtarpati Bhawan.