February 2007 - Posts
Tivo always suggests some music shows from my girlfriend's viewing habits. I've normally just let them fall off, but recently I've been watching more and more MTV. I'm doing research for an application that targets the MTV market using new mobile phone technologies.
Almost throughout every episode you can text something somewhere and get something. If you want to subscribe to jokes text: "Fun1" to 66300, or "Ring this song as your ringtone, text "22354". And that's through the show. I've started watching more of the commercials because this is a commercial application and I want to understand how that market uses their mobile phones.
I went to the kitchen for a commercial and come back and see soap on the TV screen with naked women behind it. It is blurry looking through the soap, but then she squeegees the window slowly, seductively. Her voice is pleading the viewers to "Let us [some had two women] clean your cell phone window, text <something>". Man...you press 6 buttons and basically have access to a strip show on a pocket sized device.
Came across this little gem today. I've always hated string concatenation in javascript. I know there are performance issues related to string building in javascript, but that was the least of my concern. It is just too damn hard to read and maintain code
var input = '<input type="radio" id="' + this.name.value + i.toString() + '" name="' + this.group.value + '" value="' + this.value.toString() + '" />;
MS Ajax has a String.format function that behaves similar to the server side version where you get to do the nice little {0} string replacements. It makes code much easier to read. And code that is easier to read and maintain is cheaper code (read: cost effective).
The same string written above looks so much nicer using String.format.
var input = String.format( '<input type="radio" id="{0}" name="{1}" value="{2}" />'
, this.name.value + i.toString()
, this.group.value
, this.value.toString() );
I hope this adds a little bit of readability and reduces the level of frustration when dealing with javascript and counting ' and " to close out strings. I really want a javascript validator/compiler.
I use IE for 95% of my web browsing. It is mostly out of habit, and it seems to open faster when I just want to look something quickly up on the web. However, when developing I spend half my time in FireFox and IE. I routinely use Fiddler to check out some of the chatter of my applications.
When I open Fiddler is automatically hooks into the IE 6 chain and I see the traffic, local and otherwise. IE 7 does not do this automatically and is why I haven't upgraded my machine to IE 7, but I digress. You manually have to set up a proxy when using FireFox to "localhost:8888". 8888 is the proxy port that Fiddler listens to. When Fiddler isn't open you can't see any pages.
Finally the meat of my post. I'd like a plug in for firefox that would first try 8888 as a proxy and if that didn't exist, it would remove the proxy port and see if it had connectivity. Right now when I open firefox I have the choice of either opening Fiddler so I can browse with FireFox, or I can go into the settings of FireFox and remove the proxy server information.
I just don't have the time now to create the "Fiddler Switcher" plug in for firefox. So I'm going to ask everyone else to do something for me. Please write it. I'll donate for it because of the lost time and productivity this issue is causing me.
I've been carrying this control around for a while. Mostly because I built this on an early version of MS Ajax, back when it was still called Atlas. I've finally updated it to MS Ajax RTM. My friend Neils is an avid accessibility guy. He was frustrated by the manner in which he had to wire up labels with their associated input control.
The issue brings itself up when you are using master pages, user controls...basically any control that implements INamingContainer. To wire up the for attribute to the correct ID you must either:
You can make the label runat="server" taking up server side resources.
<label runat="server" for="FirstName">First Name: </label>
<asp:TextBox id="FirstName" runat="server" />
or you can inject the generated ClientID from the control into the label element. Also using up server side resources.
<label for="<%=FirstName.ClientID %>">First Name: </label>
<asp:TextBox ID="FirstName" runat="server" />
Using the BillRob.WebControls.LabelAutoAssigner control will allow you to not use any server resources to wire up any labels. You simply give the for attribute the value that the control has on the page. For example
<label for="FirstName">First Name: </label>
<asp:TextBox id="FirstName" runat="server" />
Notice there is no runat="server" attribute. When the page is loaded at the browser the LabelAutoAssigner does its magic. It finds every <label> control on the page and checks its htmlFor attribute. (notice in javascript it's htmlFor and not for.) It first checks for sibling <input>, <select>, or <textarea> tags and checks to see if the client ID ends with its htmlFor attribute. In the case above, it will look for an id ending with "_FirstName".
It then walks up each parentNode and checks the children. If it hits the root of the document nothing happens and the algorithm jumps to the next label.
INSTRUCTIONS FOR USE
1. Drop the BillRob.WebControls.dll into your bin directory.
2. Register the dll for page consumption.
Either in the web.config
<system.web>
<pages>
<controls>
<add tagPrefix="BillRob" namespace="BillRob.WebControls" assembly="BillRob.WebControls"/>
</controls>
</pages>
</system.web>
Or on the page itself.
<%@ Register TagPrefix="BillRob" Namespace="BillRob.WebControls" Assembly="BillRob.WebControls" %>
3. Drop the control on a page. You should place on your master page. It can be placed more than once and it will only execute once. Also if there are no labels on the page, no ill will befall.
<BillRob:LabelAutoAssigner ID="Assigner" runat="server" />
I'm open for suggestions on this or if you find a specific pattern that this control doesn't handle, let me know and I'll get it updated.
I just spent 2 minutes of my life waiting for my computer to respond and started this blog post before I could go back to work. I hit F2 trying to rename a file in my solution, but studio quit responding. I started getting more and more frustrated that studio died. I had some unsaved files (yes my problem) and didn't want to lose them.
The the screen flashed and "Initializing Help" came up. Ah yes, the accidental F1 key press that locks studio down why the integrated help is activated. OMG. Google is a better "help" than studio has to offer. I could reassign that keypress to something innocuous, but I've finally learned to live with the studio default keys. It makes it easier going to someone else's machine.
I've been spending a lot of time lately writing javascript and would kill for an intellisense engine. It's like programming back in my hobby days writing code in notepad...or actually VI because Linux had "gcc" built into the OS. The Orcas Studio demos I've seen were impressive for javascript intellisense. I hope Orcas solves the frozen-Studio-accidental-F1-keypress-malevolent-joke.
Like many of my blog posts, this one is because I solved a frustration today and wanted to share. I have always been a code-behind type guy. I liked having my code seperate from my presentation...whatever.
With Studio 2005, there was the 'magical' addition of the Resolve context menu item, and the much improved the intellisense parsing for code-inline aspx pages. When dealing in true .cs only files I begin typing my Type I'm looking for, if it doesn't pop in intellisense to get the quick space for completion, I carefully type out the real Class name and case it properly. Then I hit my Context Menu shortcut key type 's' and hit enter twice. 'using System.Collections.Generics' pops at the top for future use with zero time lost.
However in the code inline world, if you use the Resolve feature, it will complete the namespace name only on that instance you are typing. It won't automatically add the page directive to get the same effect as using.
<%@ Import Namespace="BillRob.WebControls" %>
I've always been frustrated by the fact the Resolve doesn't work as well as I'd like for code-inline pages. You can automatically add namespaces to your pages by making a modification to your web.config. If you are like me, you have sections of your config file you move between projects. You can add a section to your web.config under system.web/pages/namespaces
<
pages validateRequest="false" enableSessionState="false" enableEventValidation="false" autoEventWireup="true" pageBaseType="CommunityServer.Components.CSPage, CommunityServer.Components">
<namespaces>
<add namespace="BilRob.WebControl"/>
<add namespace="CommunityServer.Components"/>
</namespaces>
More Posts