Customizing Style of RadGrid Edit Items#

A developer wanted to customize his “edit” form with a telerik rad grid, and we found it less than simple to change the textboxes and other edit controls to make them more narrow, and/or other customizations.

 

I did some research and came across a few different technique for doing this that I am going to share with everyone.

 

Template Columns

The first option, which is the one he used because it is the easiest, is to convert your columns to “template columns.”  Converting columns changes:

 

<telerik:GridBoundColumn DataField="EmployeeEmail" DataType="System.Int32" HeaderText="EmployeeEmail"

SortExpression="EmployeeEmail" UniqueName="EmployeeEmail" />

 

To this:

 

<telerik:GridTemplateColumn DataField="EmployeeEmail"

    HeaderText="EmployeeEmail" SortExpression="EmployeeEmail"

    UniqueName="EmployeeEmail">

    <EditItemTemplate>

        <asp:TextBox ID="EmployeeEmailTextBox" runat="server"

            Text='<%# Bind("EmployeeEmail") %>'></asp:TextBox>

    </EditItemTemplate>

    <ItemTemplate>

        <asp:Label ID="EmployeeEmailLabel" runat="server"

            Text='<%# Eval("EmployeeEmail") %>'></asp:Label>

    </ItemTemplate>

</telerik:GridTemplateColumn>

 

 

As you can see, this gives you control over the actual textbox item that will be displayed when you are in edit mode.

 

But using template columns can also be a bit of a pain, because you losing some of the simplicity that you had before when you simply allowed the rad grid to deal with the details of the display/edit cell items.  This also complicates things when you try to do anything in the ItemDataBound or ItemCreated events on the rad grid.  You can’t just grab the column, you have to dig deeper, looking for the contained child controls to find your actual edit control.

 

ItemDataBound

 

    Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound

        If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then

            Dim editItem As GridEditableItem = e.Item

            If TypeOf editItem.Item("EmployeeId").Controls(0) Is TextBox Then

                CType(editItem.Item("EmployeeId").Controls(0), TextBox).Width = 30

            End If

        End If

    End Sub

 

 

In this example, I am setting the width of the EmployeeId textbox to only 30px.

 

 

CreateColumnEditor

 

    Protected Sub RadGrid1_CreateColumnEditor(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCreateColumnEditorEventArgs) Handles RadGrid1.CreateColumnEditor

        If TypeOf e.ColumnEditor Is GridTextBoxColumnEditor Then

            If e.Column.UniqueName = "FirstName" Then

                CType(e.ColumnEditor, GridTextBoxColumnEditor).TextBoxStyle.Width = 30

                CType(e.ColumnEditor, GridTextBoxColumnEditor).TextBoxControl.Style.Add("text-align", "right")

            End If

        End If

    End Sub

 

 

I believe this event is fired when the grid is creating the edit columns.  You hook into this event, and then modify the textboxstyle in order to change the look of the edit control.

 

 

Defined Column Editor

 

You can achieve the same results as in CreateColumnEditor without writing any code if you drop a GridTextBoxColumnEditor on your page (outside of the RadGrid) like so:

 

<telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server">

    <TextBoxStyle Width="50px" />

</telerik:GridTextBoxColumnEditor>

 

And then in your column you specify the ID of the editor you want to use, like this:

 

<telerik:GridBoundColumn DataField="UserId" DataType="System.Int32" HeaderText="UserId" ColumnEditorID="GridTextBoxColumnEditor1"

    SortExpression="UserId" UniqueName="UserId">

</telerik:GridBoundColumn>

 

 

 

 

Categories: Programming | .Net | ASP.Net
Thursday, March 11, 2010 3:08:27 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

CSLA and the watch window#

One of my biggest complaints about using CSLA has been the issue of Visual Studio's failure to work correctly in the watch window with CSLA objects. 

I wrote a post a while back about my issues:

So for example I have a simple list called "projects" which is of type ProjectList containing ProjectListItems.

If I put "projects" in the watch window, for Value I get:

"Count = {System.TypeLoadException}"

If I put "projects(0)" in the watch window, I get:

{"The generic type 'System.Collections.ObjectModel.Collection`1' was used with the wrong number of generic arguments in assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'." : "System.Collections.ObjectModel.Collection`1"}

Rocky's response was:

This is a known issue. I've actually talked to the VS debugger team about this, and they didn't have a satisfactory answer - and certainly not a solution. This issue has existed since 2005 when generics were introduced into .NET.

Well, after doing some digging I think I have come across a few work arounds.

If I were to use the Watch Window and put:

projects.Count

it would throw an error.  But if I put:

projects.Count.ToString

then I get the correct result.

Also when picking a specific item:

projects.Item(2)

I get the same exception.  However, if I use:

CType(projects.Item(2),Object)

I get the object as expected!

I hope this helps out others as this is really important when debugging an application.

 

Categories:
Monday, March 01, 2010 4:36:14 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

CSLA Validation AmbiguousMatchException#

Ran into this error today:

failed in property IsDeleted ---> System.Reflection.AmbiguousMatchException: Ambiguous match found. at System.RuntimeType.GetPropertyImpl

I knew that we happened to have a property on our class called IsDeleted that shadowed a property in the CSLA base class, but I didn't think it should be running into this problem.

After tracking down some reference info here http://msdn.microsoft.com/en-us/library/zy0d4103.aspx I found otu that the issue isn't that we are shadowing, it's that we are shadowing while at the same time changing the type. 

The documentation seems to indicate that both situations should fail, but in my tests, the only time I got the exception was when my shadowing property had a different type.  In this case, we were using a Nullable(of boolean) while the CSLA element was just a plain old Boolean.

I guess we are going to rename our property to make things easy on ourselves, but seeing as how this is codegenerated, it's a little more of a pain than you might think.  But, oh well.

Here is some code that produces the error.  If you change the 2nd property type to a string it works ok.

imports Microsoft.VisualBasic
imports System
Imports System.Collections.Generic

public module MyModule
    sub Main
        dim target as new baseclass
        
        dim p as system.Reflection.PropertyInfo  = target.GetType().GetProperty("Prop") 
        
        wl( p.GetValue(target, nothing))

        
        RL()
    end sub

    #region "Helper methods"

    sub WL(text as object)
        Console.WriteLine(text)
    end sub

    sub WL(text as object, paramarray args as object())
        Console.WriteLine(text.ToString(), args)
    end sub
        
    sub RL()
        Console.ReadLine()
    end sub
    
    sub Break() 
        System.Diagnostics.Debugger.Break()
    end sub

    #end region

end module

public class BaseBaseClass
    public readonly property Prop as string
    get
    return "BaseBaseClass"
    end get
    end property
end class

public class BaseClass 
inherits BaseBaseClass

    public readonly property Prop as integer
    get
    return 123
    end get
    end property

end class
Categories: Programming | .Net | .Net Framework
Monday, March 01, 2010 4:02:49 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Javascript scope in for loops#

In JavaScript, you don't need to define your variables.  You can just up and use any variable as you see fit, like this:

asdfasdf = 'asdfasdf';

However, these variables will then be created in a global scope, which is bad.

I came across a bug today that involved for loops and globally undefined variables.  It's not as clear what is happening when the counter variable is first used inside the for declaration, but the result is the same: a global variable:

function test2() {
     for (i = 0; i < 10; i++) {
         alert(i);
         test3();
         alert('now i is ' + i);
     }
     alert('done');
 }

 function test3() {
     for (i = 0; i < 10; i++) {
         // do whatever here
     }
 }

In this example, test2()'s for loop will only run 1 time, because test3's loop ends up using the same variable.

To fix this problem you need to define your looping variables:

for (var i=0; i < 10; i++)

This is a best practice that you should remember to do.

Categories:
Thursday, February 18, 2010 9:44:03 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Comcast turns off your internet#

Last night, all of a sudden, my internet connection went down.

After a while, all my web requests started getting directed to a comcast page that said:

"You will need to activate your account"

telling me that I needed to download some software.  Total BS.

The link for the software didn't even work.  I tried rebooting the modem, the router, nothing worked.

So after an hour in a comcast support chat (using my EVDO card for internet) they finally added my modem back to their system (or whatever).

If you get this message, and you are not a new customer, either comcast f'ed up (which is likely because they are possibly the worst company on earth) or you didn't pay your bill.

Categories: Misc
Saturday, February 13, 2010 9:11:10 PM (Central Standard Time, UTC-06:00) #    Comments [2]  | 

 

Skype on Mac OSX#

My wife just tried to install Skype on her Mac OSX computer.  Of course it didn't work.  Nothing ever works on Macs it seems.

After lots of messing around I found some random suggestion on some forum to try this:

1. Quit Skype
2. Go to the folder “ ~/Library/Application Support/Skype/ “
3. Delete the file "shared.xml"
4. Start Skype

Amazingly, this worked.

Categories: Misc
Tuesday, February 09, 2010 2:31:38 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Disabling SSRS Subscriptions#

As far as I could find, there is no easy way to disable (not delete) an SQL Server Reporting Subscription.

We thought we had found a way to do this by changing the schedule to "run once" and set an "End Date" so that it would never run after that date.

This seemed to work, but after a restart of the server this weekend, the job executed on monday morning.

I'm not sure why it happened Monday morning ( as opposed to Sunday morning, as the machine was restarted on Saturday night) or if has anything to do with today being the first of the month, but either way, this didn't work and people were emailed some useless notice that they didn't need.

So, if you are using this method to disable your SSRS reports, watch out.

Categories:
Monday, February 01, 2010 10:58:04 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Doing P2V with HyperV#

I had recently tried to use my Windows Home Server to restore a laptop image to a VM running inside HyperV. 

In the event that my machine totally died (not just a hard drive issue) I could restore the image to a VM and work from there while I got back on my feet with a new laptop.

Unfortunately I didn't find any way to make this work.  I ended up doing all this work and in the end, I couldn't boot.

A disk read error occurred
Press ctrl+alt+delete to restart.

I tried everything I could think of, repairing the MBR, running fixboot, doing a windows repair, restoring the hal dll from i386 etc.  Nothing worked.

So I gave up on using WHS to create an instance of my dev machine, and fell back on just trying to do a P2V of any type.

I came across Disk2VHD, a free Systernals tool.  This tool includes the options to run on the source machine while online, and also provides an option to "Fix" the HAL (hardware abstraction layer).  I think this was part of my original problem (the HAL issue).  My computer was setup to use SATA drivers, and HyperV only supports virtual IDE drivers.  I think (but am not sure) that this is what was causing my problem w/ using the WHS restore.

So anyway, Disk2VHD runs super fast, and pretty soon I had a VHD to try out. 

Now, this VHD didn't work either, but it would get me further along.  I would see the windows splash screen before the black screen of death.

What followed was a weird set of steps trying to figure out why things wouldn't work, but in the end, I never ended up needing to disable anything.... so I'm just going to try to write down the steps I took as best I can.

  1. After the first BSOD I booted to safe mode (using F8).
  2. Safe mode worked, and it seemed to find some new hardware, as I would have expected, but I don't think it found any of the drivers it needed (so maybe I had ejected the virtual windows CD or something).
  3. Booting normally gave the black screen of death again.
  4. I then found this page with instructions on how to replace the HAL.  Really these instructions were how to do Disk2VHD to a working VM, but I had already done most of the steps except the hal replacement.  I'm going to replace those instructions below:
    1. 1)Downloaded Disk2VHD (v 1.3) from sysinternals (free) and unzipped on the laptop
      2)Find a place to store the new vhd - I used a 320GB external USB, but any storage device that pc can see and is big enough to hold your hard disk should work
      3)Run Disk2VHD and input the name and location for the new file
      4)On your virtual host create a new VPC (I use Virtual PC 2007) and add that new vhd you just created as the primary hard disk.
      5)Make sure you have an ISO of WinXP or an actual disk. If using an iso you'll need to mount it so it can be booted from.
      6)Fire up the new vpc and have it boot from that XP disc.
      7)Let it run setup and then select option 2 (R) to get repair console
      Login in to windows (need admin pw)
      9)Type “cd system32” press enter
      10)Assuming your CD (or mounted iso) is drive D - Type “expand d:\i386\halacpi.dl_” press enter
      11)Type “copy halacpi.dll hal.dll” press enter and then press y
      12)Reboot
      13)Press F8 to get to safe mode
      14)After the message that new stuff was installed, click OK for reboot
      15)After system boots back up, log in and install VM Additions
  5. IIRC I still got the black screen of death.  It's possible that at this point behind the scenes it was doing a check of my disck or something, but I can't tell in the VM if the HDD is going or not so I just assumed it was locked.
  6. I booted to safe mode and used MSconfig to disable everything, and also used /SOS, and some other options.
  7. What followed was just a series of successful boots with me enabling more and more until I had everything enabled and it all still worked, so I'm not sure why I was getting the BlackSOD before I started this set of SafeMode boots.
  8. Another thing I did at some point (maybe more than once) was try to install the VM Integration Services, which says that it's updating the HAL, so maybe that had something to do with it too.

The next 2 things that I'm going to try are, running a WHS restore to a VM that is already working (I don't think this will matter, but we'll see), and 2 trying to use the Disk2VHD on a machine that has a VHD mounted as a secondary drive.  I don't konw if this is even possible, but I was thinking that I could use WHS to create the VHD, mount the VHD as X: on some machine, and then tell Disk2VHD to create a VHD from X: and instruct it to to the "Fix HAL" thing.  I'm guessing that will not work as well, but we'll see.

 

Categories: Hardware | Misc
Thursday, January 28, 2010 2:28:53 PM (Central Standard Time, UTC-06:00) #    Comments [1]  | 

 

Connecting dynamically to mygeneration MyMeta.dbRoot#

The amount of time that this cost me is astounding for such a stupid issue.  (And, I'm going to lay the blame fully on whoever wrote the dbRoot object in the MyGeneration project.  Total improper use of properties).

The situation was this: I was trying to dynamically wire up all the plumbing that the mygeneration windows app does for you manually from the ZeusCmd command line.

Doing this would allow me to switch from DB to DB within my code gen application.

Because ZeusCmd runs first (it references my app and passes in what is needed), if you had previously saved a connection in your MyGeneration app, then this connection is used when ZeusCmd runs.  I didn't want this to happen because as I move from location to location different DB servers are available or not available, so if the last DB server I connected to was at office A, I didn't want my code gen crashing onload when I am out of said office.

So I ran MyGeneration and changed my connection to be <None> and saved the settings.  Then in my code gen, I tried to manually create the dbRoot object (named meta here) that was previously created for me my ZeusCmd and my saved MyGeneration settings.

Code like this:

meta.Connect("SQL", "Provider=SQLNCLI;Server=cmayt61p;Database=DBName;Trusted_Connection=yes;")

Seemed to do the trick.

However, my codegen started blowing up on my later in the process.  After tracking down the error I find that the mygeneration result column object can't figure out the .net type that would be the same as a sql server "int".  Strange, never had these problems before.

A lot of debugging leads me to find that:

meta.DbTarget
meta.Language 

Are both returning "" when before they were returning "SqlClient" and "VB.NET" when I was not dynamically connecting.

So here is where things get bad... anytime I try setting these properties to their values:

meta.DbTarget = "SqlClient"
meta.Language = "VB.NET"

Nothing happens.  The values don't appear to stick.

Eventually I even start trying to set the LanguageMappingFileName and DbTargetMappingFileName properties as well:

meta.DbTarget = "SqlClient"
meta.Language = "VB.NET"
meta.LanguageMappingFileName = "C:\Program Files\MyGeneration13\Settings\Languages.xml"
meta.DbTargetMappingFileName = "C:\Program Files\MyGeneration13\Settings\DbTargets.xml"

I tried doing these property sets before connecting and after connecting.

I tried returning to having MyGeneration setup the meta object form me (and all these properties have their values) before dynamically connecting (and losing the DbTarget and Language property values).

I even tried creating a brand new dbRoot object, as well as trying to read some hidden values in the IZeusInput object.

But, in the end, it all came down to the this 1 little thing:

You have to set the mapping file properties before you can set the DbTarget and Language properties.

So this will work just fine:

meta.Connect("SQL", "Provider=SQLNCLI;Server=cmayt61p;Database=MSiUpgraded;Trusted_Connection=yes;")
meta.LanguageMappingFileName = "C:\Program Files\MyGeneration13\Settings\Languages.xml" meta.DbTargetMappingFileName = "C:\Program Files\MyGeneration13\Settings\DbTargets.xml" meta.DbTarget = "SqlClient" meta.Language = "VB.NET"

But this won't:

meta.Connect("SQL", "Provider=SQLNCLI;Server=cmayt61p;Database=MSiUpgraded;Trusted_Connection=yes;")
meta.DbTarget = "SqlClient" meta.Language = "VB.NET" meta.LanguageMappingFileName = "C:\Program Files\MyGeneration13\Settings\Languages.xml" meta.DbTargetMappingFileName = "C:\Program Files\MyGeneration13\Settings\DbTargets.xml"

It just so happened that everywhere that I was testing this stuff in my code, I always set the DbTarget and Language properties first, and they would never stick.

This is not a proper use of properties.  If a property set has conditional logic that will prevent it from setting, there is something wrong here.  At minimum something should happen, an exception being thrown maybe?  The proper thing to do in my mind would be to make DbTarget and Language readonly properties and have functions to set their value, which could return something indicating failure (or throw an exception).

Property gets and sets should do just that, get and set properties.  There shouldn't be logic in there deciding if and when to actually perform the set that you have coded.  That is the job of a function.

UPDATE: And I discovered as well that you have to connect first before you set any of these values, or none of them will stick.  So you have to 1) connect 2) set the file paths 3) set the language and dbtargets, in that order or nothing works.

Categories: Programming | .Net
Monday, January 18, 2010 12:42:39 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

jQuery Easing Demos#

This page has a quick demo of all the easing methods in the jQuery Easing plugin:  http://www.commadot.com/jquery/easing.php

Pretty cool.  Just click on any of the boxes to see the easing action.

Categories: Programming | Javascript
Tuesday, January 05, 2010 9:49:01 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Where is the jQuery Effects Core effects.core.js #

I was trying to use some jQuery effects on this page:

http://docs.jquery.com/UI/Effects

And none of them were working.  After a while, I realized it was because I didn't have the "jQuery Effects Core" or as they list it on that page: effects.core.js

Turns out you need to download it as part of the UI package here: http://jqueryui.com/download

Categories: Programming | Javascript
Tuesday, January 05, 2010 9:31:22 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Removing all extended properties from SQL Server#

About a year ago, we tried using a tool to get our SQL schema into a souce control system.  It was supposed to work like this: every night the process would run and checkin each object as a file into TFS. 

Well, aside from not working, it also added Extended Properties to all our objects in SQL Server. 

Not really a big deal, except when we would run our database comparison tools between production and development these would cause it so that almost everything would appear out of sync.

I ended up writing my own service to check in all our SQL objects into TFS, but we were left with all these Extended Properties all over the place. 

So I finally got around to cleaning them up using the script below:

select 'EXEC sp_dropextendedproperty 
@name = ''' + sys.extended_properties.name + ''' 
,@level0type = ''schema'' 
,@level0name = ' + object_schema_name(extended_properties.major_id) + '
,@level1type = ''' + 
    CASE WHEN  
        xtype = 'U' THEN 'table'
        WHEN 
        xtype = 'FN' THEN 'function'
        WHEN 
        xtype = 'V' THEN 'view'
        WHEN 
        xtype = 'P' THEN 'procedure' end
    + '''
,@level1name = ''' + object_name(extended_properties.major_id) + ''''
from sys.extended_properties
INNER JOIN sysobjects ON sys.extended_properties.major_id  = sysobjects.id
where extended_properties.class_desc = 'OBJECT_OR_COLUMN'
and extended_properties.minor_id = 0
and extended_properties.name like 'VSS%'

This script will produce a record set that you can copy and paste into another query window to run to clean out all the extended properties. 

Note: all the generated extended properties that this tool created on our DB started with "VSS" so that is why I have that extra item in my where clause.  You'll probably want to remove that.

Categories: Programming | Database | SQL Server
Friday, December 11, 2009 11:27:26 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Tricking the HP WHS update to run on original WHS machines#

Here is the article on how to install the update on the EX47X machines.

When HP released the HP MediaSmart Server 2.5 Update for the EX48x machines, they also [1] announced the full software would not be available to first generation users due "to hardware differences" anhd "the underlying software architecture". Based on that statement, Nigel Wilks (Cougar) and Alex Kuretz (Yakuza) started work on a way[2] to make the update available to EX47x owners, dubbed "SanEncore" after the code names for the EX47x (San Juan) and the EX48x (Encore).

Cougar and Yakuza have also developed a Windows Home Server Add-In to fake the Update package into thinking it is running on a 2.1 machine, and handles some of the missing configuration items so that the 2.5 update is sucesful.

Categories: Cool | Hardware | Gadgets | Servers | Misc
Monday, November 30, 2009 10:50:48 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

CSLA 3.5 Child and Parent Patterns#
From this post:
http://forums.lhotka.net/forums/thread/25658.aspx


Child pattern:
[Serializable]
public class Child : BusinessBase<Child>
{
  internal static Child NewChild()
  {
    return DataPortal.CreateChild<Child>();
  }

  internal static Child GetChild()
  {
    return DataPortal.FetchChild<Child>();
  }

  private Child()
  { 
    MarkAsChild();
  }

  private void Child_Create()
  {
    // initialize new child here
  }

  private void Child_Fetch()
  {
    // load child data here
  }

  private void Child_Insert()
  {
    // insert child data here
  }

  private void Child_Update()
  {
    // update child data here
  }

  private void Child_DeleteSelf()
  {
    // delete child data here
  }
}

Editable root pattern:
[Serializable]
public class RootParent : BusinessBase<RootParent>
{
  // other class code here ...

  protected override void DataPortal_Insert()
  {
    using (SqlConnection cn = new SqlConnection(...))
    {
      // insert parent data here

      FieldManager.UpdateChildren();
    }
  }

  protected override void DataPortal_Update()
  {
    using (SqlConnection cn = new SqlConnection(...))
    {
      // update parent data here

      FieldManager.UpdateChildren();
    }
  }
}


Editable Root List:
[Serializable]
public class ChildList : BusinessListBase<ChildList, Child>
{
  // other class code here ...

  protected override void DataPortal_Update()
  {
    using (SqlConnection cn = new SqlConnection(...))
    {
      Child_Update();
    }
  }
}

Editable Child List:
[Serializable]
public class ChildList : BusinessListBase<ChildList, Child>
{
  internal ChildList()
  {
    MarkAsChild();
  }

  // other class code here ...
}
If you use the DataPortal methods for creating the child objects (i.e. FetchChild) then you don't have to bother with the MarkAsChild() stuff.

Categories: Programming | .Net | C#
Friday, November 27, 2009 6:12:18 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Turn an Enum into a list in VB.Net with optional CSLA#
From time to time you might have an enum that you want to databind to something as if it were a list, so I wrote some classes that turn an Enum into a list that you can databind. 

I created ways to do this in CSLA and also w/o CSLA.  I made the non-CSLA versions 1 work so that you can either use a sub class, or just use generics when defining the type of your list.  You can do the same with the CSLA versions if you want by changing some of the generics, but I didn't bother.

'*** csla
Dim cslaList As MyTestTypeList = MyTestTypeList.GetList

'*** non-csla with inherited subclass and without
Dim list As New MyTestTypeList2
Dim list2 As New EnumList2(Of MyTestType)


'*** enum we are using
Public Enum MyTestType
something = 1
here = 2
ok = 3
End Enum

'*** csla
<Serializable()> _
Public Class MyTestTypeList
Inherits EnumList(Of mytesttype, MyTestTypeList)

End Class
<Serializable()> _
Public Class EnumList(Of T As Structure, R As EnumList(Of T, R))
Inherits Csla.NameValueListBase(Of String, Integer)

Public Shared Function GetList() As R
Return Csla.DataPortal.Fetch(Of R)()
End Function

Protected Sub New()
' require use of factory method
End Sub

<Csla.RunLocal()> _
Public Overloads Sub DataPortal_Fetch() 'ByVal criteria As Object)
Me.IsReadOnly = False
For Each item As T In [Enum].GetValues(GetType(T))
Dim name As String = [Enum].GetName(GetType(T), item)
Add(New Csla.NameValueListBase(Of String, Integer).NameValuePair(name, [Enum].Parse(GetType(T), name)))
Next
Me.IsReadOnly = True
End Sub
End Class

'*** non-csla
Public Class MyTestTypeList2
Inherits EnumList2(Of MyTestType)

End Class

Public Class EnumList2(Of T As Structure)
Inherits List(Of EnumListItem)

Public Structure EnumListItem
Dim Name As String
Dim Value As Integer
Public Sub New(ByVal name As String, ByVal value As Integer)
Me.Name = name
Me.Value = value
End Sub
End Structure

Public Sub New()
For Each item As T In [Enum].GetValues(GetType(T))
Dim name As String = [Enum].GetName(GetType(T), item)
Add(New EnumListItem(name, [Enum].Parse(GetType(T), name)))
Next
End Sub

End Class


Categories: Programming | .Net | VB.Net
Friday, November 27, 2009 3:16:10 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

IBM Customer Service#

This chat takes place after I have already chatted with a different support group, called the IBM parts divions, and the IBM tech support division:

Mohammed: Thank you for accepting our chat service, how may I assist you?
you: When I customize an x3500, at last screen it says: (5652) Planar Base [$699.00] is required for this configuration and has been added for you.
you: What is Planar Base and what about my configuration makes it a requirement?
Mohammed: Is this for yourself (your company) or a client of yours?
you: mysefl
Mohammed: I see. I'm not too familiar with the planar base. I can have a specialist contact you to further discuss this need of yours
you: ok. How long does that normally take?
Mohammed: our usual turnaround is 48 hours
Mohammed: however we can try to have somebody contact you by end of day tomorrow
Mohammed: but I can't make any promises
you: ok my number is (630) 708-1234
Mohammed: May I have your full name, telephone number, email address, job title, company name and physical address?
you: Chris May, (630) 708-1234, cmay@RealNameRemoved.com that should be good
Mohammed: unfortunately without all the information requested above, I will not be able to have a specialist contact you
you: ok forget it I'll just buy a Dell

UPDATE: I did buy a Dell.  Stupid IBM couldn't have someone take 5 minutes and answer a question for someone who wanted to give them $3000. 

Categories: Hardware | Servers | Misc
Thursday, November 19, 2009 11:28:48 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Windows Stored Usernames and Passwords #

When you login to your computer as Whatever\Username, you can have windows store usernames and passwords for Something\Othername and Hello\World using the Stored Usernames and Passwords.

Getting to this dialog can be a real pain.  Just run this command from the Run dialog.

rundll32.exe keymgr.dll,KRShowKeyMgr

 

Categories: Misc
Tuesday, November 17, 2009 4:30:39 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

WHS Backup is waiting on cleanup#

Today I was trying to do a backup to my WHS and I was getting the message on my client:

Backup is waiting on (cleanup).

After quite a long time, it was still on this message.

I did some investigating on the server and saw that 45 minutes earlier my server had kicked off a backup cleanup process.  This was indicated in the event viewer under "Homeserver". 

Task Manager also showed whsbackup.exe doing a lot of work.

So, if you run into this, just wait a bit and when the server is done with the cleanup the client backup will start like normal.

Categories: Hardware | Storage | Servers | Misc
Sunday, November 15, 2009 12:54:05 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

PIX ArrayIndexOutofBoundsException#

So today I went to make some firewall updates for a client and the Cisco PDM wouldn't launch from the browser.

After some troubleshooting, I found that the Java VM was indicating an ArrayIndexOutofBoundsException had occurred.

After some checking around I confirmed my suspicion: Java sucks.  Just kidding, well not really, but what I really confirmed was that the PDM wouldn't work with any new version of Sun Java.  I guess I'm spoiled with .Net being backward compatible. 

Some suggested installing an old version of Java
http://java.sun.com/products/archive/j2se/1.4.2_03/index.html

But lucky for me I was able to just install Java 6 Update 15 and Java 6 Update 7 from Add/Remove programs and everything started working again.

It's totally true when people accuse MS of copying Java with the .NET framework, but they sure didn't make it suck like Java.

UPDATE: The version of Java that is working for me is Java 6 Update 6.  You can download it here:
http://java.sun.com/products/archive/j2se/6u6/index.html

Categories: Networking | Firewall
Friday, October 30, 2009 8:28:11 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Visual Studio type fly out windows in HTML#

I've been working on a project where I wanted to have a flyout window on the left just like how Visual Studio does their menus.

Maybe "slide out" is more accurate.

I used jQuery, which I am trying to use more in my projects, for the effects.

Anyway, I ended up making it a bit harder than it needed to be by having the tab itself slide out, as well as allow for multiple tabs.

At this point I'm happy enough to move on with a successful proof of concept, but I think if I were doing this from scratch again I wouldn't bother having the tab slide out as well.  I'd just show the sliding out window.

But, this should be a good starting point.

visualstudioflyoutmenus.htm (17.7 KB)

Update: And of course it completely fails in FF.

I made some changes, removed some things, tweaked others... looks ok in FF now.

visualstudioflyoutmenus2.htm (17.7 KB)

Categories: Programming | HTML | Javascript
Thursday, October 29, 2009 12:16:37 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

All content © 2010, Christopher May, Inc
Open Job Positions
On this page
Google Ads
This site
Calendar
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 2.3.9074.18820

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: