Tuesday, November 25, 2008

Setting the Style for div via C#.NET

Had to look this up again so documenting for quick reference. It's rather simple to set a div style using the following steps:

Step 1; The div must have a unique id and be configured with runat="server":
 <div id="myDivId" runat="server" class="head2"> 

Step 2; The code behind references the div as if it were any other Control on the page, using the Controls Style property to set a style attribute:
 myDivId.Style["background-color"] = "#ffdd77"; 

Tuesday, November 4, 2008

Setting the property for div in a ContentPlaceHolder

Following shows how to set the property for a div that is in a C#.NET ContentPlaceHolder found with Master Pages:

Step 1; in the aspx file, the div needs a unqiue id and set to runat="server":

 <asp:Content ID="conent1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <div id="myDivId" runat="server" style="display: block;"> <p>foo bar</p> </div> </asp:Content> 

Step 2; In the aspx.cs file, the ContentPlaceHolderId is retrieved first using the Page.Master.FindControl and then used to reference the div:

 ContentPlaceHolder content = (ContentPlaceHolder)Page.Master.FindControl("ContentPlaceHolder1"); content.FindControl("myDivId").Visible = false; 

Wednesday, October 8, 2008

Missing standard for minimum URL length.

Applications differ on their support for the length of a URL because the specification fails to indicate any requirement for a minimum length (http://www.w3.org/Addressing/URL/url-spec.txt). MS Internet Explorer, for example, only support 2046 characters in it’s address box, a fraction of what other contemporary browsers will support. The Microsoft .NET Hyperlink component supports a much shorter URL, silently truncating the address, and Office applications and desktop shortcuts will fail to recognize links of even a moderate size.

The impact of this missing standard is that URLs with complex queries cannot be constructed or used reliably by many applications.

While there are design alternatives, such as using POST to send data to a server based session, any design choice that does not maintain the explicit page state in the URL will likely confuse users. That is, users expect that if they bookmark a page, they can come back to that page, even after a server side session has expired, and it will render identically. Other web paradigms include using the Web browsers back button to undo an action, something that .NET and AJAX applications frequently fail at since they tend to not update the URL when updating the page state. For a demonstration of this, observe how even MS’s Live.com site maintains page state in the URL rather then use the .NET paradigm of post backs to the server.

While maintaining page state in the URL is desirable the inconsistency of support for URL lengths ensures the design will, in some case or another, fail. The failure may happen in such a way that the user is unaware of the failure –as when additional query parameters are truncated and the resulting page is not as expected. For example, a query that contains key=foo+AND+bar” and is truncated to key=foo would likely result in a silent failure.

To defend against these silent failures a Web application must be designed to test for a truncated URL. How this is done depends upon the application. For example, in one application a special character or keyword may be is placed at the end of an applications URL if it contains a query. In another, the query includes a parameter for URL length that is tested for.

The key is that is that the pages URL cannot be assumed to be valid unless there is a test for validity.

Sunday, April 20, 2008

My 2000 BMW F650

My fun little BMW F650 "beach cruiser". Not what you'd expect - not a typical BMW nor is it even a typical cruiser. Think more along the lines of those "beach bicycles" - sturdy and capable.

Not mine, just placeholder of same make/color till I find a pic.

It was a common site to see Suzette and I out and about town on the bike. We'd go for drives to check out the neighborhoods, cruise the beach, or head over to Petty's for some lunch. We'd ride to church in the summer, two deacons showing up with motorcycle helmets, much to the titter of the church ladies.

The bike had more than enough refinement that it would look good where ever it went. It looked like a much more expensive machine, sort of like the R1200 RT's little brother (which in effect it was). When riding this bike, people would stop, stare, and start a conversation.

Suzee learned how to ride on it. Yes, all though she did not pursue a license, she could ride. She said she preferred to ride on the back of mine. Snuggling.

This 650cc single cylinder Rotax engine had enough torque to haul us up and down the side roads. The frame and suspension was surprising comfortable. The bike had nice features, such as fuel injection, heated hand grips, and I'd even added the full side bags for those occasions we'd want to bring a lunch.

On those days I'd head out on my own, the bike was sporty enough to be a joy to ride - though no threat to a sport bike - it would cut through the hills with vigor. Despite the plastic cowl and all, I'd take it out and toss some dirt on the trails, weave between the trees, and handle the less challenging off road rides following the local BMW group.

Other, more accomplished, riders of this model bike have crossed continents.


This bike ran flawlessly for the couple of years I had it. I'd like to think that was because it was well loved. And that I'd learned the lesson with past bikes on how important maintenance was to a good ride.


I sold it when we moved to New York City. Living in midtown Manhattan - where everything can be reached via taxi or subway - made having a vehicle unnecessary. If we were going to ride a bike from the city it would have to be big enough to handle the highway, with both of us on it, for the trip back up to NH.

It's one of those bikes I'll always remember with a smile.