|
|
|
[
aspnet
]
One of the ASP.NET features that will be officially mainstreamed in the .NET Framework 3.5 SP1 release is browser history. (Video) (The feature has been available in Futures releases and in the SP1 beta for a while.) In my editing role I keep crossing paths with the browser history feature, and in my limited exposure to it, I kept thinking that the examples I was seeing were sort of trivial.[1] In particular, the examples I was seeing either a) showed history for a single state change or b) in worse cases, were examples that didn't really require the feature at all. So I played with it a while until I was satisfied that I got the gist of it.
Lightning explanation for those who don't know this feature. AJAX-enabled pages usually perform asynchronous postbacks that result in a change to the page. You click a check box; async postback; page changes. Click button; async postback; page changes. However, the browser doesn't know about these async postbacks. If you now click the Back button, the browser unloads the current page, pops a URL off the history stack, and goes to that URL. What you probably wanted, tho, was to just return to the previous state, not to the previous page.
In brief, browser history works like this: during the async postback, you call the AddHistoryPoint method of the ScriptManager control. In the call, you pass a name/value pair, where the value is some value that you want to save. Like this:
ScriptManager1.AddHistoryPoint("ListBox1", ListBox1.SelectedValue, title)The new history point that ASP.NET creates consists of the URL of the current page (you want to "return" to the current page, after all) plus the encoded history state data. This history point is then pushed onto the browser's history stack. It might look like this:
http://mikepope.com/ajaxsite/browserhistorydemo.aspx# &&/wEXAgUITGlzdEJveDEFAUIFDHJiWWVzTm9NYXliZWX2lkuhyaKYQlMDywFZQlslYekHBQ== (Wrapped for your convenience.[2])
The junk after the #&& characters is the encoded history point data. (By default it's base64, I believe, but it can be encrypted.)
The user now clicks the Back button. The browser pops the history stack and loads the URL saved earlier (which points to the current page). ASP.NET also raises a Navigation event wherein it passes you the history state data you saved earlier. You reset things to the value(s) represented by this state. From the user's POV, the Back button did the right thing -- it returned to the previous state. Note that it's up to you to determine what to save as history data and how to restore it.
One of the things I was not initially grasping was how a name/value pair could store all the state I might need. The examples I was seeing showed how to store the state of something like a single text box. I was imagining that there might be all sorts of state data to store, and how did I do that?
Well, duh. Turns out you call AddHistoryPoint for each history datum you want to save. If you want to store state for (e.g.) two controls, you might do this:
ScriptManager1.AddHistoryPoint("rbYesNoMaybe", rbYesNoMaybe, title) ScriptManager1.AddHistoryPoint("ListBox1", ListBox1.SelectedValue, title)ASP.NET constructs the single history-state data string from all of these calls. Notice that each call specifies a different value, sure, but also a different name (rbYesNoMaybe, ListBox1). ASP.NET then pushes the URL onto the stack. When the user clicks Back, you get the whole dictionary back, and you can pick your way through it to revert the state of however many individual controls you saved for that history point.
Anyway, I created a simple history state in action for multiple controls. In this example, each time you click Register Choices, the code stores history for both the radio buttons and for the list box. When you click Back or Forward, the handler for the Navigate event resets both controls.
You can see the source as well:There's more to all of this (isn't there always), but this was the thing that was bothering me and that I wanted to explore a little.
posted at
03:52 PM
|
trackback
|
|
link
|
Thursday, 3 July 2008
|
Roundup
|
[
aspnet
]
I'm running ASP.NET version 3.5. Or am I? The evidence is a little ... confusing. Let's have a look.
If I open VWD 2008 Express and click Help > About, I get this:

The New Web Site dialog box says this:

The Property Pages dialog box for a Web site tells you:

Suppose, however, that I have a peek at the headers sent by ASP.NET when I request a page (thanks here to Fiddler):

That's odd, no?
Or the even-more-confusing issue of where to find the .NET Framework tools. If you read about aspnet_regsql.exe on MSDN, you'll find this:

So we go to %windir%\Microsoft.NET\Framework\:

You can hunt all you want in v3.0 or v3.5, but you won't find aspnet_regsql.exe. I'll save you a teeny bit of trouble and tell you that you will find it, tho, in %windir%\Microsoft.NET\Framework\v2.0.50727.
So am I running ASP.NET 3.5 or ASP.NET 2.0?
Yes.
The issue of what version of the CLR is running has been addressed before (more than once). But it keeps coming up, and -- here's our angle -- there are doc implications. You'll find text similar to what I have above about aspnet_regsql in lots of places in the docs, and that's confusing at best, since, as you've seen, the version that you're supposed to plug into the path is hardly clear.
The best way to think of it, I suppose, it that we're all running 2.0 with 3.0 additions (and 3.5, some of us). With some exceptions, the bits that you installed with 2.0 are still there and still chugging away, even if various signs seem to indicate that you're running something called "3.0" or even "3.5". (The exceptions pertain to the bits that had to be updated to support new stuff -- the so-called red bits. See Scott Hanselman's writeup if that's interesting to you.) But if you're looking for CLR tools or if you're wondering what's become of machine.config and his sisters and his cousins and his aunts, it's the 2.0 (ahem: v2.0.50727) folder that you'll be wanting.
posted at
06:08 PM
|
trackback
|
|
link
|
Friday, 27 June 2008
|
Blogiversary: 5 years
[
blog
]
This blog went live 5 years ago today.[1] It was a kind of lark, of course. ("How hard could it be?")
Some stats:
- Entries: 1885.
- Words: 545,938. That's a lot of blather, dang.
- Average entry size: 289, or 298 if I count code.
- Hits: 917,375 or thereabouts. The, um, rigorousness of the hit counting is not guaranteed.
More stats are available over on the bottom left.
I've slowed way down in the last year or so. Partly I just don't have as much time, and partly it's because the editing game requires less daily coding, hence I've had fewer incentives to blog about my adventures and problems therewith.
As I keep saying, tho, it's just a phase.
And hey, maybe I'll even get version 2.0 of this thing out during this fiscal year. I see that from the very beginning, the idea was to "include forthcoming ASP.NET features." That was, like, in the days of ASP.NET 1.1. The team has lapped me several times by now. Oh, well. Real Soon Now. :-)
posted at
12:41 AM
|
trackback
|
|
link
|
Sunday, 22 June 2008
|
Every editor's dream
[
editing
]
Ha. Jane Black, writing in the Washington Post, recounts a little fantasy she has that is, I strongly suspect, shared by many people. People of a certain kind, that is. She says:Most people have a superhero fantasy. Some want superior strength, plus tights and a cape, to fight crime. Others imagine being able to fly, become invisible or see through walls.
Mine has always been tamer. No costume. No drama. In my fantasy, I enter a restaurant, order and sweetly ask the waiter if I can "hold on to the menu" during dinner. Then, using a distinctive purple pen, I discreetly copy-edit the descriptions of the dishes. She doesn't mean English menus in foreign lands, where the mistakes, tho often either amusing or puzzling, are at least understandable. ("Kettledrums and creaking ham," for example.) And she's not talking about the neighborhood diner she has examples from Dupont Circle restaurants, where you'd think the insane prices that buy the ambiance of elegance might also cover a wee bit of copy editing. Point being, in certain circles (<-haha, like Dupont Circle), such elegance is diminished by orthographical carelessness.
Not that it matters. English is hard to spell; chefs are cooks, not editors; a significant percentage of diners don't notice; there are, as Black notes, rather more pressing issues for restaurant managers to contend with these days. Still, I'm sure the every editor has had the same reaction in similar circumstances: "How about if I just make this little change? Ah, much better."
Original link via jason kottke.
posted at
12:42 PM
|
trackback
|
|
link
|
[
general
]
We watched TV for a bit last night -- if we're home on a Friday night, we often watch "Numb3rs," the stylish (Ridley brothers, what would you expect) CSI-type program whose shtick is that the crimes are always solved by (or at least there is always a lot of talk about) mathematical theory.[1]
When you watch TV seldom, the ads can be kind of interesting. Production values on ads are often great. Plus watching ads gives you a tiny slice of the Zeitgeist: what's on our collective minds?
Based on what we saw in the car ads, what's on everyone's mind these days is the price of gas. Every single car ad touted the vehicle's mileage rating. If one is to believe the ads, there's hardly a car for sale today that gets anything less than 27 mpg. Sarah pointed out that there were no ads for SUVs, and that got us thinking about the tough spot that the PR people for, say, the Hummer are in. With SUVs, we figured, you could emphasize capacity (many kids! many seats!) and push hard on that very hot button, namely safety.[2]
But dang, a Hummer?[3] It never was a vehicle that you could sell to soccer moms, so the kinds of tactics that you can still use to sell something like a Chevy Suburban probably don't translate well to Hummers. You could go for the gut and sell the car for what it is, but in the current climate (haha), that's apt to get you as much negative publicity as sales. Or perhaps not; I might be underestimating the power that the Hummer has for people who, you know, like things like the Hummer.
It's an interesting problem. I'm kind of curious to see what sorts of ads companies start to run now for vehicles whose operating costs are becoming more painful practically by the week. Of course, that would mean watching more TV. Is it worth it?
posted at
12:43 PM
|
trackback
|
|
link
|
Sunday, 15 June 2008
|
Single-celled organisms
[
readings | books
]
I've been reading The Canon by Natalie Angier, which she calls a "whirligig" tour of science. It's not 100% clear to me what she means by whirligig, but I might go with "giddy" (#). Angier has a style that features a lot of wordplay; think, dunno, Anthony Lane, maybe, but about science, not movies. The book tours physics, chemistry, biology, astronomythe usual suspects. It's an exuberant piece of writing, although I'm not sure I'd hand it out as an introductory textbook.[1]
I didn't want to let the book slip back to the library unmentioned, and as an inducement for you to check it out, I wanted to set something down. In the chapter on biology, I learned something that I had never thought about and that I found quite surprising. Here 'tis. (I'll note that this is an unusually subdued bit out of the book, but it was one of the more remarkable things I learned.)Nucleated or not, cells consist of three defining ingredients, and it so happens that one type of bioentity that fulfills the criteria is the egg. An egg has an outer membrane, a viscous cytoplasm that in the edible egg we call the yolk, and a set of genes only half the number of genes needed to spawn an offspring, and half the number of genes found in other body cells of the egg bearer, but a gene set nonetheless. An egg, then, before it merges its DNA with a gene set supplied by a sperm and starts developing into an embryo, is a single cell, and that goes for the egg you can see well enough to scramble. Yes, believe it or not, an unfertilized chicken egg of the kind you buy at the grocery store is a single cell, although strictly speaking it’s the cheery, marmalade-colored yolk of the egg that is bounded by the plasma membrane and thus qualifies as the cell proper. The translucent, whippable, protein-rich "egg white," the hard outer shell of calcium chloride, and the thin, slippery membrane lining the shell are all bonus coats added on later, as the yolk makes its way down the mother’s cloaca. Still, chicken yolks are no joke, and they keep getting ever more jumbo even as we fret over the wisdom of eating any eggs at all. Did you know that? Not me, man. Angier continues with a Fun Fact:The largest egg in the world, and thus the largest cell in the world, is the ostrich egg, which measures about eight by five inches and weighs three pounds with this extracellular shell, two pounds without. (Interestingly, the ostrich egg is also the smallest bird egg relative to the size of its mother, amounting to only 1 percent of the female ostrich’s body mass. The she-birds most deserving of every mother’s pity are the kiwis and hummingbirds, which lay eggs that are 25 percent as big as they are—the equivalent of a woman giving birth to a thirty-pound baby.) Dang.
posted at
10:42 AM
|
trackback
|
|
link
|
Wednesday, 11 June 2008
|
Too many helps in UI?
[
technology
]
Via Leon Bambrick, I learn that Long Zheng has created an interesting way for Windows users to complain about the Windows UI. His Web site, Windows UX Taskforce[1], combines two common ideas: user complaints and social bookmarking (as in, being able to vote for submissions). From the perspective of the company, it's great -- it's a self-prioritizing list of features to fix in future editions. (Leon suggests that we need sites like that for a bunch of stuff. Sounds good to me.)
One of the issues raised on the site was titled "Too many help texts in dialogs", which is described this way:Problem: Dialogs shouldn't be abused as the help system. Too much text clutters up the layout. Unexperienced users would need the questions once when they see the dialog for the first time, every other user has to ignore them a thousand times. This is annoying.
Examples: [...] The UAC dialog. Do we need the help text at the bottom every time? Commenters don't necessarily agree, and the posting has been demoted into negative territory (currently at -2 vs +216 for the most popular posting).
I'm torn about this one. On the one hand (which would be my user hand), I agree that dialog boxes with lots of text are intimidating. And anyway, who wants to stop and read when you're in the middle of whatever it is that the dialog box is helping you to do? On my other user hand, I like the idea of not having to go elsewhere -- Help or Web or wherever -- to figure out what I'm doing. On my third hand (my tech writer hand), I like self-explaining dialog boxes, because hey, the best documentation is not-needed documentation.[2] If the UI is self-explanatory, we don't need to create Help topics that would have little or nothing to add.
Here's one that has lots of text, but that (imo) pretty much explains itself:

Of course, the quality of the text is a factor; let's assume that the text is clear and to the point.
What do y'all think?
posted at
12:31 AM
|
trackback
|
|
link
|
[
technology | personal
]
A couple of months back, when I got my new computer, I was obliged to get a new keyboard. I just ran out and got a USB keyboard that was, um, not expensive. As it happens, I ended up with a Logitech keyboard.
I noticed even at the time that the new keyboard had keys in slightly different places, and I assumed that this would take some adjustment. A couple of weeks ago, however, I realized that this adjustment was not happening. I was constantly hitting the wrong key. For example, I'd try to go to the end of the line and end up on the next page or something.
I was surprised by how much this affected my productivity. I'd be editing, for example, completely focused on what I was typing, and then oops! WTF? Where am I? And I'd have to scroll around in the document, find where I was, and then pick up where I was. Which frequently resulted in oops! WTF? Where am I now? Or I'd be typing and realize that I was overwriting existing text all of a sudden.
I've had a laptop for a long time, and I had long since resigned myself to the unfortunate fact that I am way less productive on that machine. I just cannot type as efficiently on that keyboard, and I spend an amazing amount of time backtracking and retyping and such. But it's a tradeoff; being able to work on the bus, albeit at lowered productivity, is better than not being able to do anything.
But to lose this productivity at the desktop was not acceptable. When I finally realized that I was not adjusting to the new keyboard, then -- and only then -- did I have a close look. Oho. This is the relevant part of my work keyboard, which is identical to my old, pre-new-computer keyboard:

This is the layout of the new Logitech keyboard:

The difference is small, but it's there. Look at the positions of the Home and End and Insert keys.
And for comparison, this is the layout of my laptop:

Switching between these three layouts was apparently too much for my aging brain. The net result was not only that I did not adjust to the Logitech layout on my home keyboard, it screwed up my typing on the work machine. This had not happened before, I think, because I don't spend so much time on the laptop that it retrains my brain enough to mess up my work typing. But the comparatively small difference between the two desktops did the trick.
The only solution, of course, was to get a new keyboard for home. I went a-looking, and this time rather than just picking up the cheapest keyboard, I spent a long time looking at layouts and pretending to type. I could reject out of hand all sorts of keyboards that had what I knew was the wrong (well, "wrong") arrangements of keys. It was kind of a frustrating experience, because there are actually not as many keyboards as you'd think that a) have the right layout, b) are wired (wireless is clearly a big item), and c) didn't have sucky keys. I eventually found one, tho, a Saitek that has the right layout, almost the right feel :-) and as a bonus, is backlit.

I have nothing against the Logitech folks, but I now know that I cannot ever buy their keyboards. Either that, or I have to go out and buy enough for all the computers I work with.
A valuable lesson, and fortunately, one that wasn't too expensive. I might be too old to learn a new keyboard layout, but at least I'm not too old to (eventually) learn that I in fact need a particular layout.
posted at
12:58 PM
|
trackback
|
|
link
|
Thursday, 5 June 2008
|
The vacation getaway
[
general | readings
]
I promised (myself, anyway) a while back that I’d find some more fun cites from David Owen’s book Sheetrock & Shellac. If you’re just joining us[1], Owen is a writer who bought a 200-year-old house, and in the course of maintaining and improving the house, has learned and written a lot about home improvement. That is, specifically from the perspective of a guy who writes for a living as opposed to, you know, doing construction. As noted before, the book Sheetrock & Shellac is an enjoyably wandering tour through Owen’s adventures in building (having someone build him) a cabin.
So. With summer nearly here (except in Seattle, it appears), one’s thoughts turn to things like vacations. Are you thinking of going away this summer? Sounds like fun. But maybe you dread the hassle of packing everyone and everything up and spending hours in the car. Let alone the sharp pain you know you’ll feel when you refill the gas tank.
Here’s a novel feature of David Owen’s cabin: it’s in the same town where he and his family live. That’s right; their vacation home is something like 20 minutes away from their normal home. Owen observes the following:
I know a number of people who own or rent second homes, and many of those people eventually reach a point where getting away becomes something they yearn to get away from. Often that happens when their kids have grown old enough to formulate weekend plans of their own. It also happens when the thrill of mere novelty has faded—as always happens, since novelty is evanescent by definition. Fifteen years ago, some neighbors of ours bought a cabin in the mountains in another state. They visited faithfully, for a while. Then, gradually, the commute became irksome. Do we have to go to our wonderful, expensive place in the mountains again? their kids would whine. Summers were worse, because then the kids wanted to stay home, near their friends, and the parents were left to brood about wasted property taxes and mortgage payments. After a few years of increasingly reluctant visits, our neighbors sold their cabin to someone else, and good riddance. Hmmm. Maybe hauling the nuclears to a distant location isn’t really as much fun as it seemed. In addition to having seen the downside of having every family vacation perpetually tied to a distant investment property, Owen had had an experience that convinced him that the location for his cabin might be ideal:Experiencing a therapeutic change of scene requires less actual travel than most people generally assume. One weekend when I was ten, my parents and some of their friends took my sister and me and some of our friends to a Holiday Inn. The Holiday Inn was just on the other side of town, maybe ten miles away. None of us kids had a chance to get bored or cranky in the car on the way there; fifteen minutes after leaving home, we were splashing in the pool. We played miniature golf. We ran around. The grown-ups made cocktails and glanced toward the pool occasionally, to make sure we hadn’t drowned. We stayed less than twenty-four hours, but by the time I got home I felt as though I’d had a real vacation. It was the change, not the distance, that was significant. Perhaps you balk at the idea of a vacation home that you can bicycle to. But you might at least consider whether the weekend getaway has to be all that away. Consider the conveniences of a vacation where you could, for example, run home to pick up the mail and walk the dogs. I can see the appeal. In fact, I might go check out Holiday Inns right now.
posted at
07:54 AM
|
trackback
|
|
link
|
|
|