Pseudo-registers in VS debugger

April 12th, 2008

I found a very interesting feature of Visual Studio’s debugger. It’s been there for a long time but many developers do not know (including me) that pseudo-registers can be helpful.
There are more registers but I will mention just two of them.

@ERR

Well, it returns the same as GetLastError(), It optionally can return formatted string - just write it like @err,hr
I think I don’t need to add more, screens below are self-explanatory

Code
Watch window

$user

Provides many informations about a user executing current process

Watch window - user

Happy debugging.

Hell Helper

February 19th, 2008

I have written another tiny tool which helps me in every-day work.
Look at the projects page.

Postback from javascript - the right way

January 31st, 2008

Sometimes a programmer must do very weird things in his ASP.NET webapp. Among them, there is a postback initiated in custom javascript. Before .NET Framework 2.0, it was no good solution to achieve it. Fortunately it can be done without much effort nowadays.

There is an interface called IPostBackEventHandler which must be implemented by a page or a control. Then you must create javascript containing reference to postback function retrieved by ClientScriptManager.GetPostBackEventReference(...) method.

The sample web control's codebehind can look like below:

C#:
public class MyControl : Control, IPostBackEventHandler
{
    // this method will be called on postback initiated in javascript
    public void RaisePostBackEvent(string eventArgument)
    {
        if (eventArgument == "foo")
        {
            // do something
        }
    }
}

then we create javascript in aspx / ascx file:

ASP:
<script>
function Test()
{
    <%= Page.ClientScript.GetPostBackEventReference(this, "foo"); %>
}
</script>

Now, when a Test() function is called in a browser, our page will do a nice, clean postback :)

Quick Assembly Info

January 28th, 2008

Today I added another tiny application to my project list - click for Quick Assembly Info

MS 70-536 passed

January 27th, 2008

I have passed my first MS exam :) Although it covers many aspects of .NET, it is the most stupid exam I have ever taken (Econometrics which I passed on a 6th attempt does not count :D)
Questions are very confusing and when you do not memorize most of .NET classes and methods you will probably fail. Many possible answers differ only by method signatures and you need to know exactly when the parameter A must be on position 1 and the parameter B must be on position 2. I am a little bit disappointed because there were no questions about designing and solving problems. IMHO this kind of exam does not prove that a programmer has any useful skills.

Anyway, I'm glad I could make it :)

Designed by SirMike © All rights reserved

Valid XHTML 1.0! Valid CSS!