Tuesday, October 18, 2011
Missing File menu in visual studio 2010
I just got irritated to see the file menu in visual studio 2010 missing. All other items of the menu, e.g. Edit, View, Refactor, Project, Build etc. were showing. Only mischievous was the File item. It would be of no value for me if only I could add new project in an existing project. But I couldn't find any such option. I had to workout to recover my lost menu item back. And the way is as discussed below.
1. Run Visual Studio Command Prompt for VS2010 as Administrator
2. Navigate to C:\Program Files\Microsoft Visual Studio 10.0\Common 7
3. Run devenv with the option /ResetSettings
4. Press enter
This will reset the default settings for the visual studio and open it.
Now you see the missing File item. Thanks.
Thursday, September 29, 2011
Disable button in asp net web page to prevent multiple clicks
When a user clicks a button and the response is slow, there are chances that user may click the button again. The scenario may occur both when the button postbacks synchronously or asynchronously. This type of multiple clicks could be prevented if we could just disable the button just after the first click and enable it again when the processing is done. This is quite easy to implement the task in both the cases: synchronous and asynchronous postbacks.
Before we jump on the topic, you may learn how to click a button on enter key press in an asp.net textbox control. Similarly you may be interested in displaying google search-like watermark in an asp.net textbox control. Both the tutorials help you work with asp.net button control more interactively.
![]() |
| Fig. 1: Just after clicking asp.net button |
![]() |
| Fig. 2: After postback occurs |
If you are using ajax processing on button click, just disable the button when it is clicked and enable it when the ajax processing is done. If you are using full postback on button click, you may just make the button invisible using client-side-scripting when the click occurs. And you don't need to worry about making it visible since after postback the page will be rendered again, with the button visible as usual. In the snippet below I have shown how to 'disable' (in fact disabling won't work since the server side event is not firing) the asp.net button from client side when it is clicked.
1. Add reference to jquery file
2. Design the web form
3. Write the client scripting function with jquery
4. The code-behind.
protected void Button1_Click(object sender, EventArgs e)
{
lblMsg.Text +="Current time : "+ DateTime.Now.ToLongTimeString()+"
";
}
That's all. When you click the button you catch the client side click event and make the button just invisible. Meantime show 'processing' or similar message. If you love ajax loading image, generate one and show it. From codebehind I have just displayed current time in a label.Happy Bijaya Dashami (Dashain - the greatest festival of Hindus)!
Labels:
ASP.NET,
ASP.NET Control,
jquery
Monday, September 26, 2011
Exclusive access could not be obtained because database is in use-sql server restore database error
While publishing a website to the web server, I took backup of my database. Now I had abc.backup at my hand. Next step was to create a database in the sql server of my host. I did it. Then I uploaded the backup file to the server. When I tried to restore the database I got following error:
Exclusive access could not be obtained because the database is in useThis error normally discourages because we wonder what exclusive access is this that we need to successfully restore the database. After searching a while you come to conclusion that the database to which we are restoring our backup is in use by one or some users you have already added. The popular solution is - temporarily isolate the user from the database Easy, if you run this command at your server:
Use master go Alter Database mydbname SET SINGLE_USER With ROLLBACK IMMEDIATE RESTORE DATABASE mydbname FROM DISK = 'C:\abc.bak'Now you are right if you suspect whether we should the roll back to multi user. Yes this way:
Use master; go ALTER DATABASE mydbname SET MULTI_USER; goNote that we run the commands against the master database, not the candidate database itself. And did I do the same last time? Nope. I was just happening with a slight mistake. I had created users for the db before I restored the database. So to save yourself from all those stuffs explained above, just create the database in the server, restore your backup file to it and only then create the database users. Done! Thanks.
Labels:
database,
SQL Server 2005
Thursday, September 22, 2011
There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined
Last time I got the following error:
I got the error when I was deploying a web application precompiled in asp.net 2.0 onto the production server with asp.net 4.0. The simple search reveals that it is known issues with VS 2010 and asp.net 2.0. But my site is asp.net 2.0 enabled. What's the root of the error then?
My conclusion (and please correct me if necessary) I have configured asp.net web extension namespaces in my web.config file. You don't see this in asp.net 3.5 and 4.0 enabled sites since servers with asp,net 3.5/4.0 by default server asp.net ajax services. But asp.net 2.0 has to be ajax enabled by installing asp.net ajax extension 1.0 which you can download from here. Sensed duplicate entry of system.web.extension section group? Yes, don't include the following section group in the config section if your site runs on asp.net 2.0 but published on asp.net 3.5/4.0.
HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.See in the image below the following config error, and also watch the config source.
There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section definedRoot of the error
I got the error when I was deploying a web application precompiled in asp.net 2.0 onto the production server with asp.net 4.0. The simple search reveals that it is known issues with VS 2010 and asp.net 2.0. But my site is asp.net 2.0 enabled. What's the root of the error then?
My conclusion (and please correct me if necessary) I have configured asp.net web extension namespaces in my web.config file. You don't see this in asp.net 3.5 and 4.0 enabled sites since servers with asp,net 3.5/4.0 by default server asp.net ajax services. But asp.net 2.0 has to be ajax enabled by installing asp.net ajax extension 1.0 which you can download from here. Sensed duplicate entry of system.web.extension section group? Yes, don't include the following section group in the config section if your site runs on asp.net 2.0 but published on asp.net 3.5/4.0.
Comment out the config section (or remove it if you like), and you are done. Good luck!
Labels:
ASP.NET
Friday, September 16, 2011
How to add favicon in your asp-net site?
Make your site impressive and standard by displaying favicon. This is a practice of branding also. See in the following image the red circled area at the top corner. The black filled square is the favicon of dotnetspidor: A dot net programming blog. You can see the favicons in almost all of the popular websites.
So how to achieve this?
First create a favicon image of your own. Visualize a great logo/image for the favicon. Save it as favicon.ico. Drop it at the root folder of your site. Now you are one step away - just put the following two links just below the title of header of your form. If you are using master page, just put these lines in the master page and you are done for all the pages.
So why the two lines? Normally the first link works. But for some tricky and picky browsers the second link will work. All the best!
Subscribe to:
Posts (Atom)
Popular Posts
-
Most of the times programmers fill the DataTable from database. This action fills the schema of the database table into the DataTable . We ...
-
I have found much tricks in different tutorials and forums on opening new window in asp.net web page, using JavaScript, jquery etc. Here I h...
-
The asp.net Eval() and Bind() expressions are heavily used in asp.net GridView and DetailsView data bound controls. The difference between ...
-
I have oracle database installed in my computer. My Operating system is XP. I wrote an application in asp.net. It connected to oracle databa...
-
Last time I got the following error: HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related ...
-
Last time we talked about Refreshing the parent page from child window in asp.net using javascript . This technique is useful in many scenar...
-
In this post, I am explaining the button click functionality on key press in a textbox. I am using javascript to link the input textbox and ...
-
We do have a folder (and a number of sub folders) with a number of various files in those folders (and sub folders). Now we do need to list ...
-
Much often we open child windows from parent web page . In the child page we perform some activities, and later close the window. At the ver...
-
The default behaviour of asp.net gridview is that it hides both Gridview header and footer when no data is present. You can note the absence...







