Wednesday, August 27, 2008

Why do we not have...

A spell checker that can be run on an entire studio solution, that checks all strings, all mark-up, basically any plain text for spelling errors.

The Code Analysis stuff can now check identifiers which is nice, but why are we still lacking a feature that has been in Word forever.

Wednesday, August 20, 2008

Debugger side effects FTW

Trying to (quickly) get my generated form site working in Firefox...

The first problem was that getElementById was returning null when the client side validation function was firing. A quick look at the source and I see that the Name attribute is set but not the Id on the control that I a looking for. IE "copes" by looking at the Name if the Id is not there, Firefox though "follows the standard". Ok, so why is ASP.Net not generating an Id?

Due to time constraints I tried setting the Id when I create the control, but though it looks fine in the source and the validation works, now I don't get any data in the Text member after postback? Huh? I guess that ASP does not like it when it does not generate the Id, probably have to munge the ViewState to store my Id... No thanks.

So I am just playing in the debugger, trying to see what is populated after adding the control, maybe I can set the Id to be the same as the genereated Name... I add a watch for Control.ID, it's null, then I add a Watch for Control.ClientID, its "ctrl09", now if I just set the contr... wait a second, what?... the watch item for Control.ID just got updated with a value.

Accessing Control.ClientID causes Control.ID to be populated.

I look in the source, sure enough, for the control that I frigged with, the Id is defined. I add this after adding the control to the page:

   1: f.Control.ID = f.Control.ClientID;

And we still let ASP choose the value of the ClientId and hence the Name, but trick it into populating the Id also. (Which I really think that it should anyway...) The assignment is really only for clarity, as this works just as well:

   1: string MicrosoftIsTehSuck = f.Control.ClientID;

Which at least puts a little smile on my face...

Saturday, August 16, 2008

Windows Live Writer

I finally got it set up. A big Fuck(*) You Very Much goes out to whomever wrote the automatic configuration part. Use the damn default web browser to go get your pages, not Internet Explorer! Why would you hard code it to use Explorer? My explorer is configured to only work when I am connected to the VPN and hen only for internal addresses! I had to go change the proxy configuration (after I worked out why it wouldn't work)... Now I just wonder if other parts of Live Writer do this and get upset every time I reboot and reset the proxy configuration? Stupid.

Anyway, looks nice enough.

Where do the drafts go? ... Only local looks like for Blogger, the publish draft is greyed out.

Apparently, by installing a little code snippet (... painless) one can post neat looking code samples:

   1: <controls:PathDuplicator>
   2:     <controls:PathDuplicator.ItemStyle>
   3:         <Style TargetType="controls:Item">
   4:             <Setter Property="Template">
   5:                 <Setter.Value>
   6:                     <ControlTemplate TargetType="controls:Item">
   7:                         <Grid x:Name="RootElement" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" RenderTransformOrigin="0.8,0.8">
   8:                             <Path Margin="18,9.36900043487549,37.2080001831055,27.5090007781982" Data="M50,14 C42.942787,12.875842 37.481071,3.0378544 31,16 C29.399416,19.201166 27,22.378658 27,26 C27,31.253759 25.183334,31 34,31 C35.521332,26.436005 38.284637,24.241812 43,21 C49.555965,16.492775 47.970417,15.455626 55,26 C63.315838,38.473759 64.010223,47.474442 57,65 C55.737644,68.155891 49.410244,76.01281 43,68 C37.249264,60.811581 38.936535,57.9706 36,50 C34.534855,46.023182 28.36919,45.217796 23,51 C17.748837,56.655098 20.123365,57.791729 18,65" Fill="#00FFFFFF" Stretch="Fill" Stroke="#FF000000"  RenderTransformOrigin="0.8,0.8"/>
   9:                         </Grid>
  10:                     </ControlTemplate>
  11:                 </Setter.Value>
  12:             </Setter>
  13:         </Style>
  14:     </controls:PathDuplicator.ItemStyle>
  15: </controls:PathDuplicator>

Hrm. How does one modify the styleses? I guess if I go put them in the configuration of the blog that is easy enough. Would be nice to see the actual styles in the plugin though. Nevermind! Also, the view HTML thingy in the plugin does not show the correct html if you select not to embed the styles, it still shows only the html with the styles embedded. Also also, why not define the styles inline as actual styles rather than setting the style property of each element... just saying.

After stylish modification:

   1: public override void OnApplyTemplate() {
   2:     base.OnApplyTemplate();
   3:  
   4:     RootElement = (Panel)GetTemplateChild("RootElement");
   5:  
   6:     // Just make some transformation adjustments
   7:     for(int i = 0; i < 10; i++) {
   8:         Item item = new Item();
   9:  
  10:         #region Silly Stuff
  11:         item.Style = ItemStyle;
  12:         item.Angle = 10 * i;
  13:         #endregion
  14:  
  15:         RootElement.Children.Add(item);
  16:     }
  17: }

Well, wow. Now if only I could get Studio to do alternate line colouring... Can you do that? :) I guess I would also like to see the plugin support more of the Studio display items. But it looks pretty close to how it looks with my settings.

I guess I just need to find out when it uses each of the styles... and go create the styles for each type of code snippet...

Joy!

(*) Fuck is not in the dictionary... well now it fucking(**) is!

(**) So is that :)

[Edit] Not joy! Unjoy! What is with the 3 line spacing in the code samples?! Grumble... In fact, what is with the massive amounts of extra space all over the place. Grr.

[Edit] Fixed spacing. WLW editing still a bit dodgy, but it is easily fixable in the source edit view. Can't way that I could recommend it to anyone that does not know html – i.e. 90% of people who want to blog and would love a real WYSIMYG editor... Mind you those kind of people probably would not really care about how their markup looks - which incidentally makes it all the more vital to help them produce good markup.

Friday, August 15, 2008

Magic mystery fields

[Just found this draft post that I was waiting to post for some reason... it is from the middle of last year. Almost just a rant but I typed it up so I may as well post it.]

Liaising with customers, particularly ones who are managers of their company - highly experienced in their own field, though not in IT - can sometime suck.

I constantly find myself having to explain in detail why something cannot work that exact way or why something is a problem that needs to be worked through. Their opinion seems often to be that I don't want to do it or that I say it can't be done because I don't know how. Usually it seems to stem from the problem of what is easy for humans, or obvious to us on paper is not something that the computer can do or represents some information that the system does not have.

An example from today: Employees have 4 digit employee numbers, their cards have a single digit issue number that is used after their first replacement. When they lose their card again and get a new one the issue number increments. So employee 1234's first card is 1234, their second is 12341, third is 12342 etc. (Whoever thought this kind of arrangement was a good idea needs their fingers broken.)

There are two problems that I tried to broach today (right now, before they break the system). There will soon be the need for 5 digit employee numbers (we are up to like 8500), there seem to be some people with more than 9 cards (21, 51!). The system (of course, as it stands) cannot tell the difference between employee 10001 and the second card of employee number 1000 (also 10001). The second card of employee 10001 (100011) and the 12th card of employee 1000 etc.

Trying to explain that the system cannot just take off the last 2 numbers when the person has had more than 10 cards and take of the last 1 number otherwise, did get a little frustrating. Basically when there are 2 dynamic length fields in a composite id, without any other information it is not possible to reliably extract them.

Friday, July 11, 2008

AjaxControlLibrary

So it takes a little dicking around to do it, but you can use the DropShadowExtender with the ModalPopupExtender.

I had a little problem getting it to work some time ago, then when I noticed the DropShadow attribute on the popup class I thought that there must have been a problem with using them together so I just used the internal drop shadow. Well, after finding a couple of other issues with the DropShadow attribute, and finding no way to specify opacity or rounded corners, I went back to trying the two extenders together. The solution makes sense in the end I guess. You just need to put the drop shadow on an element inside the one that has the popup, not on the same panel.

An example should be fairly clear:

<asp:Panel ID="pExecuteProgress" runat="server" style="display:none;">
    <asp:Panel ID="pExecuteProgressContent" runat="server" CssClass="ExecuteProgress">
        <div>Processing...</div>
        <div><img alt="..." src="images/status_anim.gif" /></div>
    </asp:Panel>
    <cc1:DropShadowExtender ID="DropShadowExtender1" runat="server" TargetControlID="pExecuteProgressContent" TrackPosition="true" Opacity="0.3" Width="8" />
</asp:Panel>
<cc1:ModalPopupExtender ID="mpeExecuteProgress" runat="server" PopupControlID="pExecuteProgress" TargetControlID="pExecuteProgress" BehaviorID="ExecuteProgress" BackgroundCssClass="ModalBackground">
</cc1:ModalPopupExtender>
A couple of notes about this example:
  • I have specified the same control for the TargetControlID - it has to be non null, but I am showing this popup only via JS
  • The display:none on the outer panel is to prevent the flashing of the control on page load that you can sometimes get

Just for interest sake, here are the two css classes mentioned:

.ExecuteProgress {
  border: 1px solid #000000;
  background-color: #FFFFFF;
  padding: 30px 80px 30px 80px;
  font-family: Arial;
  font-size: large;
  color: #3366FF;
}
 
.ModalBackground {
  background-color: #C0C0C0;
  filter: alpha(opacity=70);
  opacity: 0.7;
}

I gotta find a better way to post code... I just used an online encoder to HTMLEncode the text, then it is just in a <pre> *sigh*

[Edit] Code posting fixed.

Sunday, May 18, 2008

One bad apple?

It's funny, just about every website you go to sign up on that wants your email address gives you those TWO boxes to fill in. Email and Verify Email. I don't who started this, or why everyone thinks they should follow, but I wish it would stop.

I understand where this malady came from: it was some smart web monkey seeing the Password and Validate Password combo and adopting it. But I don't think they quite understood why this mechanism is needed in that case. Just to be explicit - it is only needed because you can't read what you just typed in in the Password box. For the email address, I can re-read that just fine thanks.

Besides, I figure if you can't either type in your correct email address, or read that is not correct and correct it, then you failed my minimum user requirements. There is a certain limit to how far you need to go holding people's hands.

Wednesday, March 19, 2008

TortoiseSVN

The global ignore pattern that I am using at the moment is:

*bin *obj RECYCLER thumbs.db *Debug *Release

Which is probably fine for a single developer. When working in a team you would probably want to block *.suo also.