Creating an SPWeb From Its Absolute URI

Posted by | Filed under ,

A collegue of mine recently asked a fairly common question for SharePoint developers getting familiar with the SharePoint API; "If I have the absolute URI of my web, how do I use it to instantiate a corresponding SPWeb object?"

You'd assume that the SPWeb would have a constructor that accepts an absolute URI, but that isn't the case. What you have to do is first create an SPSite using your URI, then call the parameterless OpenWeb() method on it.

string uri = "http://server/site/subsite/web";

//remember your "using" statements so the SPSite and SPWeb are properly disposed
using(SPSite site = new SPSite(uri))
//here, OpenWeb() opens the web corresponding to the URI passed to the SPSite constructor
using (SPWeb web = site.OpenWeb())
{
    //use your web here
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Worked for Me! iPhone 3G Car Bluetooth Echo and Break Up Solution

Posted by | Filed under , ,

I love my iPhone 3G, but the one major (and I do mean major) issue for me was that there was that when it connected to my 2007 Prius' OEM Bluetooth system, there was an annoying echo and complaints of my voice frequently breaking up (though callers sounded fine to me).

Luckily, the solution was pretty simple in my case:

  1. Initiate a call via your Bluetooth system.
  2. Press the "Volume Up" button on the iPhone 3G until its "Bluetooth Volume" is cranked all the way up.

Voila, virtually no echo and the calls didn't break up any more! The difference was instant and noticeable.

If you have a Toyota, Lexus, BMW, Nissan, Infiniti, Volvo and other make of car and have the same issue, I recommend trying the solution. I used it to fix my echo/break up problem twice (once originally and once after a firmware update reset my Bluetooth volume).

Unfortunately, I discovered that it isn't working for everyone as you can see in the comments below.

 

Currently rated 2.8 by 5 people

  • Currently 2.8/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

ZvBox Hands-On Review!

Posted by | Filed under , ,

Introduction

Call me obsessed with getting internet and hard-drive content to my TV, but the day I heard the Apple TV would offer movie rentals from the internet, I not only ordered one but bought a 52" HDTV to go with it! I am ready go digital with movies like I did music back in the 90's since it's so much more convenient! However, as great as the Apple TV is, it and all other media streamers on the market suffer from the same problem: lack of broad format support.

What about the TV I record with Windows Media Center? What about the DVD's I have ripped to my hard drive? What about the streaming media I get from the internet? If I wanted to play all of these, I might need several different devices but then I'd certainly still have to deal with many unsupported formats and websites.

The ZvBox, however, takes a different and very powerful approach that ends up solving the format limitations! It hooks up to your computer and sends whatever is on the monitor to your TV screen (and in HD)! Perfect! If the ZvBox delivers on its promises, it means I will be able to watch my recorded TV, my ripped DVD’s, the movies I downloaded via iTunes and any bit of video I can find on the internet!

Well, I got my eager hands on a demo unit last week, so let’s see how it fared!

Installation

I heard mention elsewhere about how daunting the ZvBox installation was and about the true problems of it not working well with satellite cable, so I was a little worried about the difficulty of setting it up myself. I also worried about and the possibility of screwing my cable service up. Fortunately, I discovered the installation horror stories were overblown and the ZvBox didn’t interfere with my TV, phone or internet services, all of which run over cable.

Contents of the ZvBox Package

Basic hardware installation consists of hooking up a few coax cables, a channel filter near one of your home’s splitters (you’ll need to figure out where they are), and then plugging your monitor into the VGA ports of the ZvBox.

If you’re like me, one of your first questions about the ZvBox is, “Why VGA?”. Many if not most newer computers have moved to the newer DVI or HDMI standards. Well, according to my contact as ZeeVee, the reason is that along with the newer outputs comes DRM. Since VGA is analog, you get around any restrictions.

Unfortunately, what you don’t get around is the fact that a DVI-to-VGA adapter isn’t included with the ZvBox, which the majority of customers will have to purchase separately. Lame! Add another $20 to the price for that omission.

Functionality/User Friendliness

Once performing a channel scan and tuning into the “ZV” channel, a press of a button launches the “Zviewer” interface, which acts as a streamlined portal to sites like Hulu.com, an online service offering ad-supported on-demand movies and TV shows. That feature is a pleasant surprise with the ZvBox! I hadn’t previously used Hulu.com, mostly because I like watching TV on my TV, not my computer monitor (go figure), but since the ZvBox bridges the gap between PC to TV, Hulu is a compelling service that has me questioning if I really need to pay the extra dollars for on-demand cable service. ZvBox gives me a free alternative with a (slightly clumsy) graphical interface and about the same selection!

Screenshot of Zviewer: Hulu.com selction.
Hulu.com movie selection as seen through Zviewer.

MediaCenter interface as seen through ZvBox.
ZvBox broadcasts any PC application like Windows Media Center, which can play recorded TV and ripped DVD's.

The included RF remote (which lets you control your computer from pretty much any room in the house) is mostly familiar in terms of its controls. You have your standard play/pause/rewind buttons, directional arrows to navigate around, the easy-to-overlook “full screen” and “back” buttons for enlarging video and going to the previous screen respectively, and then a feature unique to the remote: an electrostatic touchpad mouse like you’d find on your laptop.

The touchpad is used mostly when you leave the “Zviewer” interface to utilize the “PC-to-TV” functionality that is the primary selling point of the ZvBox. Unfortunately, there is about a half second lag between any computer input and the time it hits your screen, so anytime you have to use the touchpad, it’s a bit of an annoyance. So too is the remote’s method for keyboard input, which simply provides a number pad where you can enter text similar to the way you’d send a text message on the cell phone.

The good news is that it’s usually possible to keep the touchpad and text interaction to a minimum since most of the programs you’ll want to use (iTunes, Windows Media Center, etc.) are supported by the arrow keys and play/pause/rewind buttons. If you want to do something like surf the web, which is more input intensive, you’ll either want the expensive and not-yet-released ZV keyboard, or a Bluetooth keyboard presuming your computer is in Bluetooth range of the TV(s) you want to watch.

I noticed some other quirks with the system, like sometimes having to restart the ZvBox when I restart my computer, but since the ZvBox lets me watch Hulu, iTunes, and my ripped DVD’s and recorded TV in Windows Media Center, I can forgive some of the system’s quirks, especially when much of the important nuance like automatic resolution changes to fit your TV, turning off the screen saver, and diverting audio solely to the TV is handled perfectly.

Performance

The performance of the ZvBox is mixed, but acceptable overall. The resolution is quite good (I could read 6 pt. font in the ZV channel in my experiments), I noticed no skipping (aside from when an overloaded website is buffering video), but I did notice some pixilation in darker scenes and gradients because of the signal compression, as pictured below.

Correctly displayed gradient on monitor. Pixelated gradient generated by ZvBox.
How a gradient looks on a PC monitor. This is the way it should look. How the same gradient looks when localcast via ZvBox. Notice the pixelation near the color transition.
Chronicles of Narnia as viewed through ZvBox localcasting.
'Chronicles of Narnia' looking good when localcasted via ZvBox!

Most of the time you won’t ever notice the issue and the picture looks as great as the pictured ZV channel screenshot of “Chronicles of Narnia”. because of the compression and 720p resolution, however, I wouldn’t recommend streaming 1080p sources like Blu Ray from your computer to the ZvBox.

Also, because of the noted input delay the ZvBox is great for video and music streams, but it’s not meant for gaming or applications requiring fast response to mouse and keyboard actions.



Conclusion

The ZvBox has its warts, but I’ve been waiting for a device that can play all of my media regardless of the source or format. In that regard, the ZvBox delivers! The interface isn’t quite as smooth as other streamers I own, but then it’s not optimized to play only the handful of formats those devices support. The fact that ZvBox lets you stream from Hulu, navigate Windows Media Center, plus support any website, program or file format you can throw at certainly makes it the most versatile media streamer on the market, and if you can get over its quirks and the $500 price tag, I’d recommend it!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Warning About .NET Framework 3.5 SP1, SQL Server 2008 and WSS 2.0

Posted by | Filed under ,

I got this information through the grapevine. For those using the latest version of the .NET Framework and/or SQL Server 2008, but using the older version of Windows SharePoint Services, this is pretty important.

As a heads up the product team will be updating the System Requirements for WSS v2 to reflect that support for .NET Framework 3.5 and .NET Framework 3.5 SP 1 are not supported on WSS v2.  This would include Visual Studio 2008 SP 1 that includes .NET Framework 3.5 SP 1.

 

Note:  The product team will also be updating system requirements to exclude support for SQL Server 2008 as well since it did not receive exhaustive testing either.  There are no known issues with it so far but the product team feels they need to draw the line on older versions of SharePoint and what they support.

 

Symptoms

If .NET Framework 3.5 SP 1 is installed on WSS v2 the symptoms are:

 

Each web part will display the following error:

 

Web Part Error: A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe.

 

Also, the following NT Events are reported:

 

NT Event Viewer Application Log displays multiple error warnings:

Event ID: 1000

Error initializing Safe control - Assembly: Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c TypeName: * Namespace: Microsoft.SharePoint.SoapServer Error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

 

Due to the fact that .NET Framework 3.5 was not tested thoroughly we are retroactively removing support for it.

 

Workaround:

Workaround:  Uninstall In Add/Remove Programs remove Microsoft .NET Framework 3.5 SP 1 and Microsoft .NET Framework 3.0 and uninstall Microsoft .NET Framework 2.0.  Then reinstall .NET Framework 2.0 Service Pack 1 Download Here.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Adding a CSS Style & Class To An ASP.NET Page Header

Posted by | Filed under , ,

 There are a variety of techniques out there for wiring up a CSS class to an ASP.NET Web Form through code. You can register a link to a CSS file via Page.Header.Controls.Add() and ASP.NET 2.0 introduced the robust WebResource framework for registering entire style sheets for a given page, but what about when you want to add a dynamic style to the HTML  header?

Typically, the technique would involve something like this:

Page.Header.Controls.Add(
    new LiteralControl(
        @"<style type='text/css'>
                /*type selector*/
                BODY
                {
                    background: Aqua;
                }
                /*class selector*/
                .myClass
                {
                    background: WhiteSmoke;
                    font-size: 20pt;
                }
                </style>
            "

        )
);

...but there are drawbacks to the approach including the need for verbose "style" tags with each chunk of CSS styles you want to add and the lack of validation on style names and values.

Luckily, there's a more sophisticated and elegant approach supported by .NET Framework 2.0 or higher using Page.Header.Stylesheet and the System.Web.UI.WebControls.Style class. With the approach, instead of having to define your CSS class using a string, you can used strongly-typed objects instead! Additionally, all of the styles you add will get added to one single style attribute in the Page header.

Style typeStyle = new Style();
typeStyle.BackColor = Color.Aqua;
Page.Header.StyleSheet.CreateStyleRule(typeStyle, null, "BODY");

Style classStyle = new Style();
classStyle.BackColor = Color.WhiteSmoke;
classStyle.Font.Size = FontUnit.Parse("20pt");
Page.Header.StyleSheet.CreateStyleRule(classStyle, null, ".MyClass");

There is, however, a drawback to the approach which is the limited number of properties available in the Style base class. For instance, if you wanted to set a value for the "margin" CSS style, you'd need to either use or create a subclass of Style that overrides the AddAttributesToRender() method.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Silverlight 2 Examples and Code Samples from Presentation

Posted by | Filed under ,

As promised, here is the code from last Monday's presentation.

The first of the example applications is a data-entry wizard showcasing dynamic animations, input controls and data binding in Silverlight 2.0. The scenario is that we wanted a new way for the user to enter data in a series of steps that didn't require a series of HTML pages.

A Silverlight 2.0 Wizard Example

You can see it by following this link, and download the code here!

The second application is a mock-video blog that demonstrates the use of markers in video created with Expression Encoder and interaction with the HtmlPage. The idea with this one is that we wanted a way to emphasize advertisement links through animations to increase user interest and, therefore, conversion rates.

A ficticious video blog that promotes the products it reviews.

You can see it by clicking here, and download it by clicking here!

 Also, in reference to the question about passing Silverlight data between pages, someone after the presentation pointed out a very important technique I didn't think to mention, namely the use of isolated storage. Issolated storage is a sandboxed area of the client's file system that you can perform file I/O on from a Silverlight application. Think of it as cookies on steroids: a place where you can read and write information that other domains can't access. It was a very great point I'd be remiss not to mention now!

Thanks to all who attended and participated in the discussion! It was a pleasure getting to present!

*** Now updated from beta for Silverlight 2 release version! ***

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

A Cool Way To Handle ASP.NET Properties Using Nullable Types

Posted by | Filed under , ,

In ASP.NET 1.x, it used to be common to handle the getter of a value type properties thusly:

public int SomeInteger
{
         get
         {
                object val = ViewState["SomeInteger"];
                return val != null ? (int)val : 0;
          }
}

Not bad, but there's more code than needed with nullable types and the "null coalescing operator", anyway. Here's the newer, sleeker way to do the same thing with half the space!

public int SomeInteger
{
         get{ return ViewState["SomeInteger"] as int? ?? 0; }
}

So what's going on in this snippet? Well, we cast the value to a nullable int (int?) which holds a reference to either an int or null then we use the aforementioned ?? operator to return our default value or 0 in the case of null

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5