http://blog.sumantdubey.com/blog/post/SQLDataSource-Passing-Null-Parameters.aspx
Tuesday, August 26, 2008
Saturday, May 24, 2008
Here comes Visual Studio 2008 and .NET Framework 3.5 Service Pack 1
Though it is still in beta stage, it won't take long for this feature packed service pack release to come to developers.
Read this post of Scott's to know what's there in the pack.
ASP:Image auto generates - style="border-width:0px;"
Read the post about a fix for this behavior of asp.net here.
Thursday, April 24, 2008
How to use BackgroundWorker component in a WPF Application
My post on 'How to use BackgroundWorker component in a WPF Application' - it's here - http://blog.sumantdubey.com/post/Using-BackgroundWorker-component-in-a-WPF-application.aspx
Friday, March 14, 2008
10000080 - Mobile phone not responding.
This is very specific to Sony Ericsson PDA phones (mine is P1i).
If you encounter any of the following behavior while taking a backup -
- 10000080 - Mobile phone not responding.
- settings cancelled by the device
- Cancelled by device.
- Failed.. etc.
Delete all old backup files and then take a new backup. If you don't want to loose old backups then you should first export them and then delete. Exported backups can be imported back any time.
I kept on struggling for days and then finally decided to Master Reset my phone. Fortunately I came across some threads on the internet where people have faced same problems and while I had tried everything else, only this was the remaining thing. And it works!
Monday, February 25, 2008
ThreadAbortException while using Response.End
Whenever there is a call to Response.End() method in your ASP.NET code, and there are lines of code following this call (which we expect not to be executed), then in such a case a System.Threading.ThreadAbortException is thrown which can be caught using a try-catch block.
This exception can also be thrown while calling Response.Redirect or Server.Transfer methods as they also call Response.End internally.
The resolution for this issue is -
- Response.End : use HttpContext.Current.ApplicationInstance.CompleteRequest instead of Response.End.
- Response.Redirect : use the overload Response.Redirect(String url, bool endResponse) where second parameter indicates if Response.End should be called or not.
- Server.Transfer : use Server.Execute
While the requirement can be different and you may not want to just replace Server.Transfer with Server.Execute, handling the exception is a better solution in such a case. Also, calling ApplicationInstance.CompleteRequest or Response.Redirect with endResponse set to false, will still go through the complete page and application life cycle which may be expensive. In this case as well, when you may want the execution to be aborted immediately, instead of workarounding this issue as mentioned above, handle the ThreadAbortException and let all threads be aborted immediately.
This issue is documented in Microsoft's KB at http://support.microsoft.com/kb/312629/EN-US/ . It states, it applies to ASP.NET 1.0 and 1.1, but it applies to 2.0 as well.
Related Articles :
Friday, February 8, 2008
View and Generate XPS
If you are not using Windows Vista or MS Office 2007 on non Vista systems, you may add XPS support by downloading XPS Viewer and Writer from here - http://www.microsoft.com/whdc/xps/viewxps.mspx
Thursday, January 31, 2008
Fill a string with repeating character (.NET)
If you want to fill a string with a character n times (e.g. 'aaaaaa') then you just have to instantiate the string and pass the character and number of times, that you want it to repeat, to the constructor.
Example:
C# : String S = new String ('a',6);
VB.NET : Dim S as String = new String ('a',6)
Thats it!
Tuesday, January 29, 2008
Thursday, January 24, 2008
Monday, December 3, 2007
Sending SMS from PC using your GSM Mobile
If you have your GSM mobile phone connected with the PC, you can send SMS to any mobile from your PC.
Many mobile vendors like Samsung, Nokia etc. provide application for this purpose in the connectivity suite itself (which comes free with the mobile or can be downloaded from the vendor's website).
However, there are other mobile vendors which don't provide an software for this out of the box, like Sony Ericsson. But, you need not worry if your connectivity kit doesn't contain a software for sending SMS, because for this we have a good and free addon for Windows XP in the market from Microsoft which is called as "Microsoft SMS Sender".
Microsoft SMS Sender supports only SMS (and not MMS etc) over GSM networks (no CDMA/TDMA support). Though it has many limitations like this, it does the basic job of sending SMS nicely and the best part is that it can be used as a command line tool. It supports various command line switches and hence can be automated using the command line options. For details on command line options, refer to the documentation in the installation package.
Friday, October 19, 2007
Upgrading existing ASP.NET project to AJAX Enabled Web Application
If you want to convert existing ASP.net web application to AJAX Enabled web application then it is as easy as just updating your existing project's web.config file, other than adding a new reference. But you need to take care of certain things otherwise this simple change might give you a tough time before you can actually start using new ASP.NET AJAX features in the existing application.
I am assuming that you have already installed ASP.NET AJAX 1.0 extension.
Following these simple steps first to add ASP.NET AJAX power to your application -
- Open your existing application and add a new reference to 'System.Web.Extensions' assembly.
- Now create a new ASP.NET AJAX enabled web application (we will use this new project to copy new settings to existing project).
- Compare new application's web.config with your existing application's web.config.
- Copy all new settings that you see in new project's web.config to existing application's web.config.
Now take care of certain things which might actually make your application behave weirdly while using ASP.NET AJAX features -
- It is very important that if your existing application is still using Legacy XHTML conformance mode, then remove this declaration from your web.config -
'<xhtmlConformance mode ="Legacy"/>'
- If your application pages are still using non xhtml or old html DOCTYPE declaration then change it to use XHTML 1.0 (at least transitional) by using this declaration instead -
"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">"
- If after doing these changes, you face some issue with intellisense in Visual Studio then you will have to change the Tag Prefix for "System.Web.Extensions" assembly from 'asp' to anything else. For this locate this line in your application's web.config -
"<add tagPrefix="ajax" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"
and replace the tagPrefix="asp" with tagPrefix="ajax" (or anything of your choice).
Now instead of using <asp:ScriptManager> or <asp:UpdatePanel>, you will have to use this new prefix (like <ajax:ScriptManager>). But this hack will get back your Visual Studio's intellisense working.
If after all this you are still unable to upgrade your existing ASP.NET application to ASP.NET AJAX 1.0, please feel free to write to me. :)
Monday, July 30, 2007
ASP:GridView - making Pager always visible
You would have noticed this while implementing ASP.net GridView control that if the record count in the grid is lesser than the grid's page size, then the pager doesn't appear.
There can be times when you want the pager to be visible all the time (like when you implement custom paging). In such a case there is no property available in the grid which can directly let you do so. But, there is a workaround to make this happen.
To make this happen, you will have to do following -
1. Handle the GridView's PreRender event.
2. In the PreRender event, fetch the GridView's 'BottomPagerRow'
3. Set BottomPagerRow's 'Visible' property to 'True'.
Example :
Private Sub gvItems_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)Handles gvItems.PreRender
Dim gv As System.Web.UI.WebControls.GridView = CType(sender, System.Web.UI.WebControls.GridView)
If Not gv Is Nothing Then
Dim PagerRow As GridViewRow = gv.BottomPagerRow
If Not PagerRow Is Nothing Then
PagerRow.Visible = True
End If
End If
End Sub
Thats it!
Saturday, June 16, 2007
Using a Master Page in ASP.net
The easiest & quickest way to get on with Master Pages
Creating a Master Page :
- Create an aspx page, as you want the basic layout to be.
- Add a new Master Page to your web app.
- Copy all code from aspx page created in step 1, exclude @Page tag
- Paste everything by replacing default code in MasterPage, keep @Page tag as it is
- Wherever you want content to appear from content pages, place a <asp:contentplaceholder> control
- Master page is ready now
The above method helps in previewing changes easily, though a master page can be created directly without using an aspx page first, and can be previewed using a content page.
Using a Master Page :
- Add a WebContentForm to web app.
- Select the master page for this page. That's it!
if its a web project, you will have to select WebForm and check 'select master page' check box while adding this page.
If a page already exist and you want to convert it to a content page, add "MasterPageFile" attribute in @Page directive of the wannabe content page and remove all html code from this page and pace <asp:content> control and the code you want to appear in content area.