Wednesday, June 03, 2009

Help me find the person who using me!

Hey Microsoft -

Error Deleting File or Folder
Cannot remove folder xyz: It is being used by another person or program.
Close any programs that might be using the file and try again.


How about telling me something useful; like which process is using the blinkin' file/folder?? Perhaps, you can call your SysInternals group and find out how to do this and put it into Windows.

With all the junk that ends up running in my tray it's needle in the haystack time trying to figure out who to shut down to get a file freed up. Help!!

Thanks,
A defender for now...

Tuesday, September 23, 2008

'CreateResourceBasedLiteralControl' is not a member of...

ERROR:
'CreateResourceBasedLiteralControl' is not a member of 'ASP.Customer_OrderForm' error was occuring on a new form that I created by copying one form to a new form.

RESOLUTION:
My mistake was that this form was part of a Web Application Project but this copy did not have a "...designer.vb" file associated. I right clicked on the form and selected "Convert to Web Application".

Wednesday, August 13, 2008

Do you want to run UrlRewriting on IIS5 for WinXP?

I have been testing the UrlRewriting framework and loving it. Unfortunately, it has been on Win2003 Server boxes and now I want to test some things on my local box. Here's how to set it up...

STEPS
1) Open IIS Manager
2) Right click on your website, select Properties
3) Select the "Home Directory" tab and click the Configuration button
4) Under "mappings", copy the path to your .net framework to the clipboard. The easiest way to do this is to double click the ".ascx" line and copy the whole path from the "Executable" box.
5) Still under "Mappings", click "Add"
6) Paste the path into the "Executeable" box, set the extension to ".*" and UNcheck the "Check that file exists" box.
7) OK, OK, OK and you're done.

Tuesday, July 15, 2008

RequiredFieldValidator and DropDownList

At first glance it seemed that using a RequiredFieldValidator against a DropDownList control with a "Select one..." option in it was not viable. I have used CompareValidators in place of this as well.

Turns out you can set InitialValue="" (assuming your Select one... item has a Value="") and everything works like a champ.

Monday, June 09, 2008

Flash links...

You should never, ever link directly to swf files. Use the flash Satay technique and you will be happy forever knowing that you will never have to go back and change the markup for newer versions of flash:







Courtesy: http://www.qrayg.com/

Friday, June 06, 2008

KISS - checkbox validator

Is it just me or is the fact that Microsoft practically prohibits you from validating a checkbox or list a little odd? Even a custom validator won't let you specify a checkbox as the 'ControlToValidate'.

I've seen people writing custom checkbox validator controls etc. How about a simple solution that still allows you to leverage the ValidationSummary? Try the following:

Steps:
  1. Add a 'CustomValidator' to your form and set it's Text and ErrorMessage
  2. DO NOT set it's ControlToValidate. Leave it blank.
  3. Now double-click your new validator and write your custom validation logic as follows:

    protected void valAcceptTandC_ServerValidate(object source, ServerValidateEventArgs args)
    {
    if (!chkAcceptTandC.Checked) // Must accept terms and conditions...
    {
    args.IsValid = false;
    }
    }

Now wasn't that easy...nobody needs to spend this much time on a simple Terms and Conditions checkbox!

Thursday, June 05, 2008

asp:Wizard and StepNextButton event handling

Exploring the asp:Wizard web control from System.Web.UI.WebControls.Wizard has truly been a ton of fun. Lots of good stuff for building the common Wizard metaphor.

In C#, I did find one confusing situation and thought I would document it for others.

I was simply trying to handle the next button. My first thought was to "Edit Templates" (from design view) and double click the next button to create an appropriate handler which it did. Unfortunately, I found it create this handler with the following signature:


protected void StepNextButton_Click1(object sender, EventArgs e)


This did not work, because I needed access to the e.Cancel property to prevent movement to the next step on failed validations. EventArgs has no such property. After searching online examples, I saw people using functions with signatures as below. The WizardNavigationEventArgs had the e.Cancel property I needed. This must be my solution!
protected void StepNextButton_Click(object sender, WizardNavigationEventArgs e)

So I tried the following:
  1. First, I tried to create an event handler with the proper signature as shown in the last example. This failed with an ASP.Net error "No overload for 'StepNextButton_Click' matches delegate 'System.EventHandler'".
  2. Next, I used the "EventArgs" signature and tried to cast 'e' to WizardNavigationEventArgs. This compiled okay but failed at runtime with a types not compatible error.

What's a developer to do?

S0lution:

  • Go into "source mode" for your ASPX/ASCX page, find your 'asp:Wizard' tag and add the attribute. NOTE: It must be on the Wizard tag and not the in the 'asp:Button' tag of the '
    StepNavigationTemplate'.
    OnNextButtonClick="wizardMain_NextButtonClick"
  • In your .cs codebehind, do the following:

    protected void wizardMain_NextButtonClick(object sender,
    WizardNavigationEventArgs e)