I would like to know who thought it was a good idea to remove "import data..." and "export data..." from this particular flavor of the worst front end to an otherwise badass rdbms. I shouldn't have to fight with a program to get my databases in order. What a joke.

[ Nothing Playing. ]

I recently ran into a neat little nugget of functionality in C# with events. Normally in C# when we define events we stop at something like this:

public event EventHandler<MyEventArgs> MyEvent;

The thing is, you can explicitly implement the add and remove accessors if you throw some curly braces into the mix. Why does this matter? Imagine that you have a MainForm, and a usercontrol named ControlPanel. ControlPanel contains another usercontrol called hiddenControl that exposes an event that you want to handle in MainForm, but all MainForm has access to is ControlPanel...

public event EventHandler<MyEventArgs> MyEvent{
	add{
		this.hiddenControl.MyEvent += value;
	}
	remove{
		this.hiddenControl.MyEvent -= value;
	}
}

Now you can subscribe to the event in MainForm without making the usercontrol member public in ControlPanel.

[ Currently Playing : Burn Away - Foo Fighters - One by One (4:57) ]

 

Rather surprised by the new 'updates are ready' message from Microsoft. Hmmm.

revised updates message from microsoft

Perhaps they know just how much frustration we had on the home pc recently due to their dodgy updates.

(Fixed thanks to Scott Swigart)

Source: Windows Updates Make Me Nervous

This is just a re-statement of a forum thread that discusses the fix, but since gotdotnet is not going to be around very much longer I thought I'd post this little tidbit here as well. Basically, when I upgraded one of my sites to .net 2.0, skmMenu got upgraded right along with it. The only issue was that all of my menus would show up at the far left corner of the screen, and when you try to navigate to them over there they disappear thanks to the menu items between the cursor and the target. I think I only saw this behavior in firefox, but the code fix works in both firefox and IE. I just went thru the .js file and the javascript in the .resx for embedded javascript goodness and placed a 'px' after any integer value. The reason for this is that firefox requires measurement properties be set with appropriate identifiers when it's displaying a structured document. Anyways, here's a reprint of the code:

function skm_mousedOverMenu(menuID,elem,parent,displayedVertically,imageSource){
	skm_stopTick();
	skm_closeSubMenus(elem);
	var childID=elem.id+"-subMenu";  // Display child menu if needed
	if (document.getElementById(childID)!=null){  // make the child menu visible and specify that its position is specified in absolute coordinates
		document.getElementById(childID).style.display='block';
		document.getElementById(childID).style.position='absolute';
		skm_OpenMenuItems = skm_OpenMenuItems.concat(childID);
		if (displayedVertically){ // Set the child menu's left and top attributes according to the menu's offsets
			document.getElementById(childID).style.left=skm_getAscendingLefts(parent)+parent.offsetWidth+'px';
			document.getElementById(childID).style.top=skm_getAscendingTops(elem)+'px';
			var visibleWidth=parseInt(window.outerWidth?window.outerWidth-9:document.body.clientWidth,10+'px');
			if ((parseInt(document.getElementById(childID).offsetLeft,10+'px')+parseInt(document.getElementById(childID).offsetWidth,10+'px'))>visibleWidth) {
				document.getElementById(childID).style.left=visibleWidth-parseInt(document.getElementById(childID).offsetWidth,10+'px');
			}
		}else{  // Set the child menu's left and top attributes according to the menu's offsets
			document.getElementById(childID).style.left=skm_getAscendingLefts(elem)+'px';
			document.getElementById(childID).style.top=skm_getAscendingTops(parent)+parent.offsetHeight+'px';
			if (document.getElementById(childID).offsetWidth<elem.offsetWidth)
				document.getElementById(childID).style.width=elem.offsetWidth+'px';
		}
	}
	if (skm_SelectedMenuStyleInfos[menuID] != null) skm_SelectedMenuStyleInfos[menuID].applyToElement(elem);
	if (skm_highlightTopMenus[menuID]){
		var eId=elem.id+'';
		while (eId.indexOf('-subMenu')>=0){
			eId=eId.substring(0, eId.lastIndexOf('-subMenu'));
			skm_SelectedMenuStyleInfos[menuID].applyToElement(document.getElementById(eId));
		}
	}	
	if (imageSource!=''){
		setimage(elem,imageSource)
	}
}
function skm_shimSetVisibility(makevisible, tableid){
	var tblRef=document.getElementById(tableid);
	var IfrRef=document.getElementById('shim'+tableid);
	if (tblRef!=null && IfrRef!=null){
		if(makevisible){
			IfrRef.style.width=tblRef.offsetWidth+'px';
			IfrRef.style.height=tblRef.offsetHeight+'px';
			IfrRef.style.top=tblRef.style.top+'px';
			IfrRef.style.left=tblRef.style.left+'px';
			IfrRef.style.zIndex=tblRef.style.zIndex-1;
			IfrRef.style.display="block";
		}else{
			IfrRef.style.display="none";
		}
	}
}

These were the only two functions that needed code adjustment. Enjoy.

[ Currently Playing : Mannequin Republic - At the Drive-In - Relationship of Command [Japan (3:02) ]

I read this excellent post from ScottGu and decided to use it with a page that implemented a masterpage. I didn't have to use postbacks in my scenario, but there were links included from the masterpage. The problem is that if you use app-relative paths for your href attributes (ex: <a href="http://weblogs.asp.net/default.aspx">) the browser (FF 2.0.0.2 and IE 7 anyways) interperets the url with pathinfo differently than a url without. The base url includes the original page (ex: http://localhost:3333/rewriter.aspx/default.aspx). Guess what? The webserver picks up the last .aspx extension, default.aspx, that bad boy doesn't exist, and you get a 404 instead of going to http://localhost:3333/default.aspx.

In the comments, Ian Oxley suggested that you can re-base links in your page/css/other static files using the <base> element in the head of your page. I expanded on it a little, since this behavior is only on one page of my site currently, and added the following code into the Page_Load event of the offending page:

this.Header.Controls.Add(new LiteralControl("<base href=\"" + Request.Url.ToString().Replace(Request.RawUrl, "").Replace(Request.PathInfo, "") + "\">"));

Now the base tag works on both the live site and the one that WebDev.WebServer spins up as well.

[ Currently Playing : Them Bones - Alice in Chains - Nothing Safe: Best of the Box (2:29) ]

So I've been able to dig my teeth into some asp.net hacking recently, and I've been wrestling with learning to use SubSonic in the process.

In dealing with the scaffold control I ran into a funny issue: none of the exposed properties on the scaffold control will output any style info of the GridView that the control uses (that I could figure out anyways). I ended up with black text on a black background. :/ Seeing as I have the source, I decided to give the scaffold control's GridView a little class...hello GridViewCssClass property! I set it up just like the EditTable*CssClass properties, just a string property, with similar attributes to the other properties hanging around there:

[Bindable(true)]
[Category("Display")]
[Description("Sets the CSS class used by the gridview.")]
[DefaultValue(ScaffoldCSS.WRAPPER)] //CDF: just to have something to start with.
public string GridViewCssClass {
	get { return _gridViewCssClass; }
	set { _gridViewCssClass = value; }
}

Then, in the CreateGrid method make it actually do something:

        private void CreateGrid()
        {
            Label lblTitle = new Label();
            surroundingPanel.Controls.Add(lblTitle);
            lblTitle.Text = "<h2>" + schema.Name + " Admin</h2>";

            grid.ID = "grid";
	    grid.CssClass = this.GridViewCssClass;

            surroundingPanel.Controls.Add(grid);

            if (!Page.IsPostBack)
            {
                BindGrid(String.Empty);
            }
            //add a column to the grid for editing
        }

And now I can declaratively set the CssClass that the GridView uses to, oh, say, .whitetext :)

I love the PostXING tool and the ability to integrate the playing music. Feature wise they are all about the same though. So it will interesting to see the evolution of the tool.

One positive out of the project is that I learned a lot about Subversion and how to work with it.

Share this post: Email it! | bookmark it! | digg it! | reddit!

[Via It's my life... And I live it...]

Well, this post has been a long time coming. What about PostXING? What indeed? Well, unfortunately for the 1.5 users of PostXING, I had my son Ethan for 6 weeks this summer and spending time with him is waaay more important than hacking on a tool that is basically useful only to a handful of people.

Then there's the issue of competition: I have always recommended BlogJet for people that wanted a good solid blog posting tool that is way more polished than PostXING (and indeed Windows Live Writer) and whose project lead is a really nice, engaging dude. Heck, Dmitry even gave me pointers on how to work with mshtml as I was writing code that competes with his (guess he wasn't too worried about "competition" from PostXING. heh.) And of course the new hip kid on the block Windows Live Writer...what can I say? Even Tomer, who was gracious enough to help me out on developing PostXING, agrees: Windows Live Writer kicks ass. The fact that it's free doesn't help the situation.

At this point I'm not 100% sure what I want to do with PostXING. I had been looking into yet another mshtml wrapper that supposedly handles focus better than the code I have, but my experience so far with mshtml is that it's a focus stealing *** child of wysiwyg editing. The good news: you can actually use a widget that gives you wysiwyg editing without having to install a browser plugin (I'm looking at you, Mono!) The bad news: didn't you read that *** child statement earlier? Geez.

Tentatively what will happen is I will continue to quietly hack on PostXING in order to at least bring it out of beta. But I'm definitely going to be taking my time on it...I am in no hurry at all.

Exactly what I was looking for...I don't know a lot about reflection, so I wonder if there is a more elegant way to get this info.

There are a few things that have to happen for this "regression" to show up. First, you have to be working in .net 2.0 WinForms. Second, you must be using a custom application context. Third and most importantly, you must have at least one form open in your application that handles its closing event and sets CancelEventArgs.Cancel = true.

What's the behavior? While operating under a custom ApplicationContext, what would be my Main form is closed by the user. Since the application context is not associated with that form, I decide to call "Application.Exit()" in an override of OnClosing. My Main form closes, but any hidden forms stick around, thus leaving the application running until you open up task manager (or something similar) and manually kill the process.

Why does it happen? WinForms 2.0 introduced an overload to Application.Exit that accepts a CancelEventArgs parameter. This is what is called by Application.Exit(). If even one of your open forms doesn't think it needs to close itself for whatever reason and sets its CancelEventArgs to true, Application.Exit stops processing and returns control to the application.

Why did I call it a "regression"? This behavior has changed between .net 1.1 and 2.0. In 1.1, if I call Application.Exit, by golly the application exits! I understand the reasoning behind the change. I just wish that there was some indication to it other than Reflector. A comment for intellisense perhaps? Something.

Will it matter to most WinForm projects? Probably not. If you use the default application context (by calling Application.Run(new MainForm()), which is what VS.NET spits out for you from the template) you do not have the same problem. Closing the main form exits the application as expected. If you're using a custom ApplicationContext, tho, watch out.

Close enough. This should be fun.

More Posts Next page »