Archives For May 2006

Ok, so whenever you have to copy anything in command window, you first require to set command window in mark mode (right click > Mark), and then you can select any content in window.

How about allowing command window to select any content by default without setting it in Mark mode?? You just need to make small modification in your registry.
1. Open your Registry
2. Under [HKEY_CURRENT_USERConsole], find DWORD Value with name QuickEdit.
4. Now double-click this DWORD Value to modify it, which will pop up a dialog box showing Value data as “0”.
5. Modify this value to “1” and click on “Ok” button to accept this change.

Now open command window and try selecting content by mouse. To copy the selected content, press “Enter” key. For pasting copied content, simply right click on command window, and you are done!

Disclaimer: Modifying the registry can cause serious problems that may require you to reinstall your operating system. I cannot guarantee that problems resulting from modifications to the registry can be solved. Use the information provided at your own risk.

Command Line Tricks

May 30, 2006 — 1 Comment

Sahil has posted some old tricks of using those old DOS commands. Some of the command tricks are really handy, but my favorite one will always remain the same. Its:

PROMPT $P$_$_  ???$_  O.O$_=(___)=$_   U$_$G

My Favorite DOS Command

Like his most previous posts, Scott Mitchell has written another simple and clean implementation of providing check/uncheck all functionality in GridView.

Checking All CheckBoxes in a GridView

Only thing his implementation was missing in article is placing CheckBox in header of GridView and using it to toggle rows CheckBoxes. I have made small modification in the existing code to provide this feature:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not Page.IsPostBack Then
Dim dirInfo As New DirectoryInfo(Request.PhysicalApplicationPath)

FileList.DataSource = dirInfo.GetFiles()
FileList.DataBind()
End If

'On every page visit we need to build up the CheckBoxIDs array
For Each gvr As GridViewRow In FileList.Rows
'Get a programmatic reference to the CheckBox control
Dim cb As CheckBox = CType(gvr.FindControl("RowLevelCheckBox"), CheckBox)

ClientScript.RegisterArrayDeclaration("CheckBoxIDs", String.Concat("'", cb.ClientID, "'"))
Next

'--modified code
Dim checkAll As New CheckBox()
checkAll.Text = ""
checkAll.ID = "checkAll"
checkAll.Attributes.Add("onclick", "ChangeAllCheckBoxStates(this.checked);")
FileList.HeaderRow.Cells(0).Controls.Add(checkAll)

End Sub

Check/Uncheck All

NAnt is powerful scripting tool designed for developers, software process engineers, and build specialists to create an automated, repeatable process for building their developed application. Though its do assist developers to automate those same mundane tasks every evening but still most hesitate to use this tool their software developer process. NAnt provides powerful XML-based scripting and some really cool features, as Jean-Paul Boodhoo explains in his series of post “Automating Your Builds With NAnt”, which can streamline your development effort dramatically.

Automating Your Builds With NAnt – Part 1
Automating Your Builds With NAnt – Part 2
Automating Your Builds With NAnt – Part 3
Automating Your Builds With NAnt – Part 4
Automating Your Builds With NAnt – Part 5
Automating Your Builds With NAnt – Part 6
Automating Your Builds With NAnt – Part 7

Does a designer require thinking from code behind aspect of the site? Yes, as Mark Boulton suggesting in his article, designers need not to learn any code to design any site but they just need to change the way they conceive different attributes in web sites. Must read!

Designers, Engage Your Brain

K. Scott Allen has written two great articles on using Master Page in ASP.NET. Through these articles Scott tried to address some of the common problems usually faced by developer.

URL:
Master Pages In ASP.NET 2.0
Master Pages: Tips, Tricks, and Traps

Working with dynamic controls in ASP.NET is real pain for developer. First you have to create instance of control, then to configure all properties of control through code and then to look for any container control where you can drop this dynamic control. Interestingly, you also have to recreate same dynamic control on every PostBack.

Let’s start will simple example to work with dynamic control:

Label dynamicLabel = new Label();
dynamicLabel.ID = "dynamicLabel";
dynamicLabel.Width = Unit.Pixel(200);
dynamicLabel.Text = "Test Text";
Page.Controls.Add(dynamicLabel);

This code will simply add a dynamic label in Page.

But how we can position this control to specific location in the page? That should be easy, we can use Top & Left property of this control! But if you check the properties of Label, there is no Top or Left property available. So then how we can set its location?? Well, using style attribute of control. But for that you also have to set control position style as absolute. Like this:

Label dynamicLabel = new Label();
dynamicLabel.ID = "dynamicLabel";
dynamicLabel.Width = Unit.Pixel(200);
dynamicLabel.Style.Add("POSITION", "absolute");
dynamicLabel.Style.Add("TOP", "100px");
dynamicLabel.Style.Add("LEFT", "200px");
dynamicLabel.Text = "Test Text";
Page.Controls.Add(dynamicLabel);

Continue Reading…

As most of the locking mechanism works in window based application, like if there is no activity by user for say 10 minutes, application automatically pops up a login dialog box to re-authenticate himself again. Whereas in web based application, being a stateless environment, its bit difficult to implement same kind of feature of auto redirecting user to login page after specific time duration.

But if we can utilize refresh attribute of meta tag, we do can achieve same kind of page flow in ASP.NET. Just put below meta snippet in header of your page.

<meta http-equiv="refresh" content=" 600;url=http://www.application.com/Login.aspx?Redirect=<%= Request.Url.AbsoluteUri %>">

First value of content attribute is number of seconds (10 minutes in above case) page will wait before redirection and next value specified the URL where page will redirect (here it will redirect to the Login.aspx page).

So test this application, minimize the wait to lesser time say 20 seconds, and run the application. Page will automatically redirect to specified page.

Alan has written a series of some good class design and implementation guidelines post.
URL: Object Design and Implementation

Rule #1: Practice Drawing Make Good Classes
Rule #2: Documation!
Rule #3: Alan’s Class Template (“ACT”)
Rule #4: Never Walk, But Fly!!!
Rule #5: Always evaluate How We Fly!
Rule #6: No Private Variable Shall Have Direct Access to the Class Public Interface
Rule #7 & #8: All about Numbers!!

Snippet Compiler

May 27, 2006 — Leave a comment

Here is a useful .NET utility if you only want to test 8 line code and without getting involve in launching that bulky VS.NET, and then creating project etc.

URL: Snippet Compiler
Download: 2.0.8.3 for .NET 2.0 | 2.0.7.1 for .NET 1.1

Some of the interesting features I like in Snippet Compiler:
> It minimize to the system tray of task bar.
> It can also builds WinForm EXEs, console EXEs or DLLs.
> You can compile multiple C#, VB.NET ASP.NET code.
> It can be used to store templates library as well.
> IntelliSense for static members and method
> You can also export your snippet in HTML format which can be post in your blog.

Snippet Compiler Screenshot