Friday, July 17, 2009

Upgrading to IE8 breaks debugging with Visual Studio 2005


I found the below article very useful. I guess it might help few others as well. After I upgraded my IE to version 8, I was not able to Debug. Then I googled for a long time, after which I got the below article.

The work around which I did to resolve this issue is as given below.

Modify the registry as described in the second link above. This worked for me as well. Here are the steps:

1. Open RegEdit
2. Browse to HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main
3. Add a DWORD value called TabProcGrowth with a value of 0

Check the original article at the link
Upgrading to IE8 breaks debugging with Visual Studio 2005


Thanks To The Original Publisher Of This Article.


Friday, May 8, 2009

Errors While Building The Project In Visual Studio


Hi I recently faced an issue in building one of my project. I searched lots to get the solution. Not sure as how many people will face this issue. But I learned a new thing as well with this error.

For any project we can specify "Pre Build Events" and "Post Build Events". If the error is of below kind, then there might be some problem in the Pre Build or Post Build events which might be trying to copy some file.

Error: The command "<Some File Name>" exited with code 1.

In that case just check the "Pre Build Events" and "Post Build Events" under the "Project Properties" window "Build Events" section.

Hope this will help some one who is struck like me.


Tuesday, March 10, 2009

Validate A Control When Its Focus Is Lost


Hi,

I tried to do this when one of my friend asked me for this. This is actually a good idea, instead of validating the controls after submitting the page. So I searched over the net to achieve this and finally found a piece of code. Thought to put this here so that it might be helpful to others as well :)

I took 2 TextBox on the page with 2 RequiredFieldValidator, one for each TextBox. Then go to the Page_Load event of the page and give the following code, which will add the "onblur" event to each TextBox with the "ValidatorOnChange" event which is actually raised when a control needs to be validated, this is already declared in the validation scripts.


TextBox1.Attributes.Add("onblur","ValidatorOnChange(event);")
TextBox2.Attributes.Add("onblur","ValidatorOnChange(event);")



That's it... this will do the work. In case if you want to restrict moving to next control until the control is properly validated, give SetFocusOnError property of the Validation Control to "true".

Hope this will help you...

Monday, March 2, 2009

Combine Array values to String



Hi, in this section I wanted to tell you a simple way to combine an Array of values in
to string delimited by a character. We can do this very easily by using "String.Join". Below is a simple example as how we can do this.


Dim aTemp As String() = {"1", "14", "23", "7", "13", "37", "143"}
Dim sDelimiter As String = ","
MsgBox(String.Join(sDelimiter, aTemp))


We need not loop through and combine with some logic which will even increase the processing time, this function will do it as we wanted. We can specify what ever delimiter we want.

Hope this will help you at some point of time. Happy Coding :)


Wednesday, February 25, 2009

Using LINQ To Query The Result

Hi, in this section we will have glance at the querying language gifted by Microsoft. Using LINQ(.NET Language-Integrated Query) we can search an array of values and get the result as we do in the databases. A small example for this is

Dim arrValues As ArrayList = New ArrayList

arrValues.Add(1)
arrValues.Add(15)
arrValues.Add(4)
arrValues.Add(13)
arrValues.Add(21)
arrValues.Add(10)
arrValues.Add(7)
arrValues.Add(17)
arrValues.Add(3)

Dim arrRes As IEnumerable(Of Integer)= From s _
As Integer In arrValues Where s >= 10
Dim temp As String = ""
For Each nTemp As Integer In arrRes
temp = temp + Convert.ToString(nTemp) + ","
Next
MsgBox(temp)



You can even give Order or your search as below.

Dim arrRes As IEnumerable(Of Integer)= From s _
As Integer In
arrValues Where s >= 10 Order By s


or Sort Descendingly by using as below.

Dim arrRes As IEnumerable(Of Integer)= From s _
As Integer In arrValues Where s >= 10 Order By s Descending


You can get more information on LINQ at
Microsoft Link LINQ: .NET Language-Integrated Query

Happy Learning :)



Wednesday, February 18, 2009

Move Control At Runtime In Windows Applications


In this tutorial lets see as how we can move the controls at run time. This can be applied to any control. Here I took one Label, one TextBox and one Button.

Start a Windows application and add a Label, Button and TextBox to the form. Then Create 3 methods to handle MouseDown, MouseMove and MouseUp events of the controls. You can easily do this by just selecting this event for any of the control you have added and then add the other controls names also at the Handles part. The functions will look as below...

Private Sub ControlMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown, Label1.MouseDown, TextBox1.MouseDown

End Sub

Private Sub ControlMouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove, Label1.MouseMove, TextBox1.MouseMove

End Sub

Private Sub ControlMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp, Label1.MouseUp, TextBox1.MouseUp

End Sub


Later you need to write few lines of code... Complete code is given below.


'' Declare Two Public Variables
Dim isDragged As Boolean = False

Dim ptStartPosition As Point



Private Sub ControlMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown, Label1.MouseDown, TextBox1.MouseDown

Dim ctrlTemp As Control = sender

If e.Button = Windows.Forms.MouseButtons.Left Then

isDragged = True

ptStartPosition = New Point(Me.MousePosition.X- Me.Location.X - 4, Me.MousePosition.Y- Me.Location.Y - 30)
ctrlTemp.Location = ptStartPosition
Else
isDragged = False
End If

End Sub

Private Sub ControlMouseMove(ByVal sender As Object,ByVal e As System.Windows.Forms.MouseEventArgs) HandlesButton1.MouseMove, Label1.MouseMove, TextBox1.MouseMove

Dim ctrlTemp As Control = sender

Dim ptEndPosition As Point

If isDragged Then
ptEndPosition = New Point(Me.MousePosition.X- Me.Location.X - 4 - (ctrlTemp.Size.Width /2), Me.MousePosition.Y - Me.Location.Y - 30 - (ctrlTemp.Size.Height / 2))
ctrlTemp.Location = ptEndPosition
End If

End Sub

Private Sub ControlMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp, Label1.MouseUp, TextBox1.MouseUp

isDragged = False

End Sub


This will do the work.... Now you can change the position of the control at any time. You can save the position in some configuration file so that the position will be saved even after restarting the application.