Erik Porter's Blog

Life and Development at Microsoft and Other Technology Discussions

News

    October 2004 - Posts

    ASP.NET Testing
    This is more of a survey than an informational entry, but I'm just kind of curious if anyone has done any UI testing for ASP.NET.  If so, what would you recommend?  Please leave comments...thanks!  :)
    Posted: Oct 29 2004, 04:26 PM by HumanCompiler | with 4 comment(s)
    Filed under:
    Change Owner of an Object in SQL Server 2000

    This is mostly just a post for me so I never forget this, but to change the owner of an object in sql server, use sp_changeobjectowner, just pass it the name of the object (as a string) and the name of the new owner (as a string)

    UPDATE: Thanks to Matthew Gibson for correcting my typo on the stored procedure to call.

    Quick Validation Hack for ASP.NET

    So in the current project I'm working on, I have a calculated field in a hidden field (server control) and I wanted an actual textbox on the page to validate against that hidden value using the CompareValidator, but unfortunately, it won't compare against hidden fields (even though it's a server control).  So what's the way around this?  Instead of a hidden field, make it a TextBox Server Control and add style="display:none" onto it, so it doesn't show up and the CompareValidator will work just fine.  This is kind of silly, but it works!

    Posted: Oct 27 2004, 04:27 PM by HumanCompiler | with 7 comment(s)
    Filed under: ,
    Cool Whidbey Data Feature

    Was just in a chat and found out about a new feature called "Smart Captions".  When you drag a table out from the Data Sources Window specified to be a Detail View, it will create all the Labels and TextBoxes (or whatever is appropriate for that field).  Smart Captions will take a field named "FirstName" and set the Label's Text Property to "First Name".  How cool is that?  Thanks, Microsoft!

    Strange DataTable Behavior

    Today, I ran into what I think is a bug in DataTable.  I created a table with two fields as the primary key and one other varchar field that is named the same name as the table.  Probably not a best practice, but hey, it made sense for once.  Let's say my table is named MyTable.  I have two fields in the PK named, MyOtherTable1ID and MyOtherTable2ID and a varchar field called MyTable.

    Now, when I load that into a DataTable (in my case a persisted DataSet using ReadXml), this is now my Columns Collection in the DataTable:

    • MyOtherTable1ID
    • MyOtherTable2ID
    • MyTable_Id
    • MyTable_Id_0

    Where did it come up with those two extra fields and where's the MyTable field?  I know I really shouldn't name a field the same name as the table anyway, but why doesn't it "just work"?  Is this a bug for sure?  Have other people seen this?  If I change the MyTable field to MyTableValue (or anything other than the table name), it works just fine.  What's up?  :-\

    Posted: Oct 13 2004, 02:08 PM by HumanCompiler | with no comments
    Filed under:
    WindowsForms QuickTip: Me.Owner

    Want to access the parent form when using ShowDialog to show a form?  Consider the following where Form1 is the parent and Form2 is the child to be shown modally.

    Dim Form2 As New Form2
    Form2.ShowDialog()
    Form2.Dispose()

    If this is in a Button.Click in Form1, this will show Form2 modally from Form1.  Now say you need to access Form1 from Form2 to possibly call a Public Method to set it's StatusBar.Text or whatever.

    DirectCast(Me.Owner, Form1).SetStatusBarText("I own you!")

    Unfortunately, this doesn't "just work" like I'd expect (maybe you do too).  So you can do one of two things to get Owner to return the Form that is showing it modally.  Either manually set Form2.Owner = Me before calling ShowDialog or just pass Form1 into ShowDialog like so.

    Dim Form2 As New Form2
    Form2.ShowDialog(Me)
    Form2.Dispose()

    Doing it this way still makes it feels sort of "built-in" in my opinion and allows you to access the parent form without having to setup your own properties.

    MVP Re-Award
    I got the e-mail on Friday.  I will be an MVP for another year!  :)
    Posted: Oct 04 2004, 01:07 PM by HumanCompiler | with 7 comment(s)
    Filed under:
    More Posts