Archives

Archives / 2009 / January
  • Twin Cities SharePoint Camp Winter 2009 (and jQuery)

    I stepped out the front door and watched my breath turn to ice crystals in the moonlight…the sun hadn't risen yet. As I walked to the garage, my shoes crunched loudly on the packed snow and when I opened the car door, the metal-on-metal shrieking of cold-friction gave my skin goose bumps. The temperature was -13F below zero and it was a Saturday morning. What on this earth would compel a man to leave a warm bed and face such bitter cold on a weekend?

    Answer: The Twin Cities SharePoint Camp hosted by New Horizons of Minnesota!

    The event was on Saturday, January 24, 2009 and almost 200 brave souls gave up their Saturday and defied the brutally cold weather to attend. I had used SharePoint at a client's site and have seen numerous posts about it on Asp.Net forums where I am a moderator. But I wanted to learn more.

    The seminars were very good and well received by the audiences. A common thread was how difficult it was to accomplish small things in large organizations…I had no idea what they were talking about.

    The presenters used self deprecating humor and invited audience participation and feedback in the seminars. There was lots of interesting and useful give-and-take between the presenters and audience. The SharePoint community is a fun group. Much information was exchanged.

    Miscellaneous Observations:

    The presenters wore matching snazzy red and black shirts; I thought they looked professional. A few, apparently, do not shave on weekends…maybe they were protesting being required to wear matching outfits like MacDonald's employees.

    I had never seen such a high percentage of women at a technical event. Around 30 percent of the attendees were women. It was a welcome change from most technical events. Maybe they attended because they have a thing for men in uniform.

    Most of the seminars were not mere Power Point presentations but were live demonstrations on setting up and running SharePoint applications. If you've ever presented/demonstrated software to a group, you know how dangerous this can be. As to be expected, there were a few glitches, but it actually demonstrated the knowledge and expertise of the presenters when they were able to effectively work their way through the problems.

    Summary:

    I now know enough about SharePoint to talk about it intelligently. But, to be honest, the most useful information I took away was in one of the free magazines given out ('Code' Jan/Feb 2009). There was an excellent article called An Introduction to jQuery, Part 1 by Rick Strahl …I couldn't wait to get home so I could start playing with it (see below).

    Of course there was the usual swag:

    SWAG

    jQuery:

    Initially, JQuery syntax looks as cryptic as Regular Expressions, but once some of the fundamentals are understood, it becomes much easier. Being able to select elements by using CSS selectors is great if you already know CSS.

    Here is my first jQuery code:

        <script type="text/javascript" src="jquery.js"></script>         
        <script type="text/javascript">
     
            // ---- After document is loaded, run this -----
     
            $(document).ready(
                function()
                {               
                    MyJScript();
                }
            )
     
            // ---- MyJScript -------------------------
     
            function MyJScript()
            {
                // get all TextBoxes with class MyInput
                var TextBoxes = $(".MyInput");
     
                // if any TextBoxes are blank, set the
                // background color to yellow
                TextBoxes.each(
                    function Yellowize()
                    {
                        if (this.value == "")
                            this.style.backgroundColor = "yellow";
                    }
                )
            }
     
        </script>

    I hope you found this helpful or at least interesting.

    Steve Wellens

  • Internet Explorer 7 and CSS….DOH!

    I wanted a cheap, simple visual indicator similar to a progress bar. Note, not the kind of dynamic progress bar used when updating AJAX pages, more of a single-bar graph. It should have been simple task.

    My plan was to use a Div as a container, implemented through a panel because they are more convenient to work with. Inside the Div I would put a Label control (which renders as a Span element) with an opaque background color, 100% height, and the width being the percentage done of the progress bar value.

    I dropped the controls on the page, added a function to set the percentage and it looked good. And then I looked closer…what the heck (WTH)?

    You can see the label is shifted down one pixel. Not a big deal, but…perfection is in the details.

    I spent time playing with CSS settings trying to get the Label inside the Div to line up correctly. I tried using a read-only textbox instead of a label but alas, IE7 and CSS are more stubborn then I am.

    I then tried using a Div inside of a Div with a Label in the inner Div to hold the text. It worked but the Asp code was ridiculous looking with its three nested elements. The code was too ugly for me to tolerate.

    Finally, I got it back to simple code by putting a Label inside of a Label without using a Div.

    Here is the Asp code for both versions of the ProgressBar:

        You have this much gas left in the tank:<br />
        <asp:Panel ID="ProgressBarContainer1" runat="server" 
            Height="18px" Width="324px" 
            Style="border-color: Black; border-width: 1px; border-style: solid;" 
            HorizontalAlign="Left">
            <asp:Label  ID="LabelProgressBar1" runat="server" 
                Text="10%"
                Height="100%" 
                Width="10%"
                BackColor="Yellow">
            </asp:Label>
        </asp:Panel>
        <br />
     
        Your project is this late:<br />
        <asp:Label ID="ProgressBarContainer2" runat="server" 
            Height="18px" Width="324px" 
            Style="border-color: Black; border-width: 1px; border-style: solid;">       
            <asp:Label ID="LabelProgressBar2" runat="server" 
                Text="10%" 
                Height="100%" 
                Width="10%" 
                BackColor="Yellow">
            </asp:Label>
        </asp:Label>

    Here is the function that updates the Progress Bar. I left the code in the affects both implementations:

        // ---- UpdateProgressBar -------------------------------
     
        void UpdateProgressBar(int Percent)
        {
            if (Percent < 0)
                Percent = 0;
            if (Percent > 100)
                Percent = 100;
     
            // first implementation
            LabelProgressBar1.Width = new Unit(Percent, UnitType.Percentage);
            LabelProgressBar1.Text = String.Format("{0}%", Percent);
     
            // second implementation
            LabelProgressBar2.Width = new Unit(Percent, UnitType.Percentage);
            LabelProgressBar2.Text = String.Format("{0}%", Percent);       
        }

    Here are both versions of the ProgressBar:

    Of course, this would be much nicer as a user control…but I didn't want to take away from the two points of this post:

    • Sometimes easy things are hard.
    • Sometimes it's hard to find easy solutions.

    I hope someone finds this helpful.

    Steve Wellens

  • Anonymous Macros…Awesome Power!

    Once upon a time, in the chilly windowless basement of a Fortune 100 company, a young programmer joined our small development team. He brought with him a programmers editor called Brief. Within weeks every developer in the entire company was using this powerful editor. The three compelling features were the ability to select copy and paste columns of text, multiple windows with cut and paste between them and…drum roll please…macros. With macros, enormously tedious tasks can be performed easily in seconds.