Showing posts from September 29, 2013

VS 2005 Team System VB.NET Unit Test Class and method name are case sensitive

I had changed the name of a class to match Code Analysis class name criteria that specifies what parts of a class name should be upper case/lower case.  I did a global search and replace.  Some time later I ran a unit test and got this error: System.TypeLoadException: Could not load type After a bit of research I discovered that even though the class I had changed casing on was a VB class the unit test class is case sensitive.

ASP.NET 2.0 Wizard Control - Cancelling the next/previous button

If your using the ASP.NET 2.0 Wizard control and you want to stop the next button from going to the next step you have to set the event arg property Cancel to true like so: Private Sub Wizard1_NextButtonClick( ByVal sender As Object , ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.NextButtonClick e.Cancel = True End Sub

ASP.NET 2.0 Stack Overflow error in Wizard control

Was using the MaintainScrollPositionOnPostback=true in a page directive with the ASP.Net 2.0 Wizard control and started getting a stack overflow error when clicking on a Sidebar button.  Could not find a decent fix so I opted for a workaround and removed the MaintainScrollPositionOnPostback attribute and implemented this:

ASP.NET 2.0 RegularExpessionValidator to exclude a specific line.

Say you had the following select: < select id ="ItemSelect" runat ="server">   < option selected ="selected"> Select your item </ option >   < option > Item one </ option >   < option > Item two </ option >  < option > Item three </ option > </ select > And you wanted to force the user to select Item one/two/three. You could do this by creating a RegularExpressionValidator to to accept anything but the “Select your item” option like so: < asp : RegularExpressionValidator ID ="ItemRegularExpressionValidator" runat ="server" ControlToValidate ="ItemSelect" ErrorMessage ="Item Required" Text ="*" SetFocusOnError ="true" ValidationExpression ="^((?!Select your item).)*$"></ asp : RegularExpressionValidator >

Copy contents of a windows popup dialog

Some windows dialog's allow you to highlight part of the text in the dialog and press ctrl-c to copy that text which is great. But some dialog's do not allow this for example this one: I wanted to copy the the compile error but it won't let me. What you can do in this situation is just click on the dialog title bar to make sure it is selected and press ctrl-c . This copies the whole dialog and then just open Notepad and paste it in Notepad like this: Then you can highlight the text you want and carry on.

Handling the SelectedIndexedChanged event of a DropDownList in a GridView in ASP.NET 2.0

Say you had a GridView with a dropdownlist like this: < asp : GridView ID ="testGridView" runat ="server">     < Columns >         < asp : BoundField DataField ="TestField" />         < asp : TemplateField >             < ItemTemplate >                 < asp : DropDownList ID ="TestDropDownList" runat ="server" AutoPostBack ="true">                     < asp : ListItem Value ="1"> Item 1 </ asp : ListItem >                     < asp : ListItem Value ="2"> Item 2 </ asp : ListItem >                 </ asp : DropDownList >             </ ItemTemplate >         </ asp : TemplateField >     </ Columns > </ asp : GridView > And you set it’s datasource in the page load event like this: Protected  Sub Page_Load( ByVal sender As Object , ByVal e As System.EventArgs) Handles Me .

Using VB.NET reflection to get a list of the current objects private fields

If you want to get a list of the current objects private fields you can do so like this: me .GetType.GetFields(system.Reflection.BindingFlags.Instance or Reflection.BindingFlags.NonPublic)