Category: Tutorial

Agile Product Ownership in a Nutshell

Want to learn what Agile product ownership means? Then checkout this video from Henrik Kniberg. It’s 2 days worth of learning squished to a 15 minute video and I must say it is very well-done. Definitely worth watching if you want to understand how to manage projects the “Agile way”.

How To: Determine what Adobe Flash version is currently installed in a machine using C#

Here are two ways you can determine what version of Adobe Flash is currently installed in a machine using C#.

1. You can read the Registry entry for Adobe Flash player located in HKEY_LOCAL_MACHINE\SOFTWARE\MACROMEDIA\FLASHPLAYER and read the value for CurrentVersion key

2. Use Reflection by creating a new SWFObject (Flash Object) and reading its version property

Both functions will give you the version number in the form of a string for the currently installed Adobe Flash in your machine.

I personally preffer the Reflection method since it is cleaner and not dependent on registry key paths.

How To: View web page source in Safari Browser

Safari_Browser_Advanced_Tab

By default, Safari web browser does not allow you to view source files of a web page. In order for you to have this feature you need to go to your Safari preference and enable the Develop menu.

To enable this menu follow these steps:

  1. While you Safari browser is open, click Safari menu.
  2. Next click Preference
  3. Then click the Advance tab
  4. In the Advance tab, find the checkbox that says “Show Develop menu in menu bar” and check it.
  5. Close the preference window and you will notice a new menu item in the menu bar appeared called “Develop”.

To view a page’s HTML source:

  1. Click “Develop” in the Safari menu bar.
  2. Then select “Show Page Source” to view the current page’s HTML source.
  3. This will show you a window containing the source code for the current page you are viewing.

Learn Windows 8 with Scott Hanselman

Probably the best Windows 8 capability demonstration I have seen. Scott Hanselman did a really good job demonstrating what you can do with Windows 8’s new interface without getting you bored.

Video Link: https://www.youtube.com/watch?feature=player_detailpage&v=wi8NpwiEuzc

Where does ClickOnce go after install?

I always forget where to find the location of ClickOnce applications so I’m putting it up here for reference.

Windows XP:C:Documents and Settings\Local SettingsApps

Windows Vista/Windows 7:C:Users\AppDataLocalApps

How To: Encrypt the ViewState in ASP.NET

Sometimes its the basic things that we tend to forget. It’s true. One example is encrypting the ViewState. Someone asked me this question today and I had to admit that I wasn’t able to answer on top of my head. Whats funny is that I’ve been doing it all along but never told myself to remember how.

Anyhow, lets go back to the topic on how to encrypt the ViewState in ASP.NET.

Prior to .NET 2.0 the way you would do this is via the machineKey element validation attribute. In .NET 2.0 onwards Microsoft provided us with an option to specify ViewState encryption in the page level or web.config level via the ViewStateEncryptionMode attribute.

ViewStateEncryptionMode has three enumeration values that you could use defending on what you need. They are Auto, Never and Always. ViewStateEncryptionMode.Auto means that the page will be encrypted if a control request for encryption. By default the value for ViewStateEncryptionMode is set to Auto. ViewStateEncryptionMode.Never means that ASP.NET will not encrypt the ViewState on your page even if a control request for it. This is a good bypassing mechanism if and only if you know that the page does not need to have ViewState encryption on it. ViewStateEncryptionMode.Always on the otherhand will encrypt your page all the time. A good practice for pages with sensitive information is to always set this ViewStateEncryptionMode to Always as you don’t want anybody compromising your ViewState.

To enable ViewState encryption in the page all you need to do is specify the value for ViewStateEncryptionMode at the Page directive

<%@Page ViewStateEncryptionMode=”Always” %>

To enable ViewState encryption via web.config to apply to the whole application

<configuration>
   <system.web>
      <pages ViewStateEncryptionMode=”Always” />
   </system.web>
</configuration>

One thing to remember though is that you can’t set ViewStateEncryptionMode via code

To request for ViewState encryption inside a control all you need to do is call RegisterViewStateEcryption() method from the Page class

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    if(Page != null)
    {
        Page.RegisterRequiresViewStateEncryption();
    }
}

Ahhh, such reverie. Now I need to remember this for future use (or questions). Cheers!

How To: Creating Tooltips in Silverlight 2

Tooltips are great additions to any interface and in this article I’m going to show you how to attach a tooltip to control in Silverlight 2.


To start, let’s assume that we have a button that we want to add a tooltip to:


[XAML]


[Rendered UI]



In order or us to attach a tooltip to our button we need to create a reference to the TooltipService.Tooltip inside the our button’s XAML declaration. We also need to setup the Tooltip.Content to tell the compiler what to show when the user hover’s to our button.


[XAML]


[Rendered UI (at runtime)]



The message “Hooray! I’m alive!” appeared when the user hovers over our button. We can also cutomize how our tooltip appears by adding more XAML elements in the Tooltip.Content property.


[XAML]


[Rendered UI (at runtime)]



Another customization that you might want to do is specifying the HorizontalOffset and the VerticalOffset. This allows you to specify where the tooltip will appear in reference to your target control.

My MIX09 10K Contest Entry: Silverlight Pregnancy Calendar

I had some free time during the holidays and saw at the MIX09 website that they have a contest entitled MIX09 10K Challenge where they ask participant to create a web application that is either using Microsoft® Silverlight™ or Windows Presentation Foundation, as a XAML Browser Application running in Partial Trust or as a ClickOnce application in 10 kilobytes or less. I decided to take a stab at it and this is what I’ve came up with

SilverCalendar: A Silverlight Pregancy Calendar

You can see the app live here http://2009.visitmix.com/MIXtify/TenKDisplay.aspx?SubmissionID=0051

Dont forget to vote when you’re there 😛 LOL

My primary motivation when I built the app is the idea of having something that is going to be useful and at the same time fun to build. My wife is currently 34 weeks pregnant and it made me think that a pregnancy calendar would be q great application to do since it relates to me and my current day to day life. I love pregnancy calendars because it gives you a good daily insight on the progress of your baby and what you might expected as you go along in your daily life as a soon to be parent.

The application that i built is using Microsoft Silverlight 2 with a backend WCF web service. You can find the pregnancy calendar web service here. I wasn’t able to add any animations to the application because I decided to concentrate in adding functionality to app rather than the eye candy’ With that said, I’ll be posting the non-10K application this week.

Be sure to comeback on this blog in the coming weeks because I’ll be publishing the source code to both project soon together with a 11 part tutorial and screencast walkthrough that i have prepared to show how to to build an application using .NET 3.5, WCF, WPF and Silverlight.

How To: Make A Master-Detail View In ASP.NET

In part 3 of this 5 part series I am going to show you how to make a Master-Detail View in ASP.NET. I you weren’t able to see the two previous post you can check them out here:



This post is a continuation of what we started in the two previous post wherein i show you how to consume a webservice ins ASP.NET and present the values returned by the service to the user in a much more meaninful way.


To start off with this post lets look at how the application from our last article look-liked:



As you can see, we have a textbox that accepts a user-input asking for the symbol to lookup in our webservice, a button that triggers that query event and a DetailsView that displays the returned resultset. This works great.


But what if I have a list of symbols that I want the user to see information regarding them? The answer is to show them in a master-detail view so that the user can get a clearer view of the information on each symbol.


To start with this demo lets begin by deleting everything that we have on the page. Yup! we are starting from scratch so that we can get a clearer picture on how we can build a master-detail view screen. Once everything is cleared on the page let’s begin by adding a DataList control on our page with a Label control inside its ItemTemplate:


The first thing that you would notice on the code above is that we have assigned a value to the Text property of our Label control. This value signifies that we are binding the Container.DataItem value to the Text property. This DataItem will come from the value that we are going to set in the codebehind file for this page which in this case is just going to be a List<string>.


Next, lets go the codebehind file and create the Page_Load event for our page:


All i did in the code above is create a list of strings, add some values to it and assign and bind that colletion of strings to our DataList. Running the application now would give us this result:



Nothing really impressive yet. Now let’s add the cool part wherein we call a web service and show the information for each stock symbol.


To do that we need to add another DataList inside the ItemTemplate of our first DataList. The second DataList will serve as the list that shows the imformation about the specified execution symbol. We also need to add an event that is triggered each time a ListItem is binded to a data. Below is our modified HTML page:


I modified the ItemTemplate of our second DataList () and added an html table to hold the values that the web service returns. This way the view that we are presenting is much more readable.


Next stop is looking at the code behind where all these magic is going to be wired. All the work for the detail view will happen on the stockDataList_ItemDataBound event and no further modification to our Page_Load event is needed. Let me show you the code for that event before I start explaining every bits and pieces of that code:


What we are doing on this blog of code is we are checking if the ItemType of the current item being binded-to is either a ListItemType.Item or ListItemType.AlternatingItem. If it passes this criteria we then read the DataItem that was binded to this ListItem which in this case is our executionSymbol. The next step is to find our stockInformationDataList control and assign the stockInformationDataSet to it. The stockInformationDataSet contains the values that is retrieved from our stock web service by passing the exection symbol to our StockQuoteHelper.GetStockQuoteDataSet method.


Running our completed application will result to this screen:



And that’s it! We’ve accomplished a master-detail view in ASP.NET. Pretty easy right? I hope you learned something from this tutorial. Next up we’ll update this project and implement some Asynchronous Web Service calls via ASP.NET AJAX and show you some fun ways to present a master-detail view in a much more interesting way.


As always, source code is available for download here: KeithRull.ConsumingWebServices.Part3.zip (6.9 KB)


As a side note, many thanks to John A. Miller from Trofholz Technologies, Inc. for reminding me about this series. I totally forgot about it already after being assigned to a large project the past few months. Thanks John!

How To: Teach Your Apps To Speak With System.Speech.SpeechSynthesizer Part 2

In part 1 of this series i showed you how to specify the voice, gender, rate and volume of the our SpeechSynthesizer object. This time i’m going to show you how to use predefined Voices in your machine and utilize it as hints to your SpeechSynthesizer object.


The first thing that I did to our sample project is change the UI since we would not need the Gender and Age combo box in our form. The result is a UI like this:



Next, we need to figure out a way to extract the names of the installed voices in our machine. To this we need to use the SpeechSynthesizer.GetInstalledVoices() method. This method, when invoked returns a readonly collection of TTS(text-to-speech) voices also known as InstalledVoice objects that are readily available in your machine. The InstalledVoice object contains a property called VoiceInfo which represents the voice information about that TTS voice. To begin our project we need to get all the VoiceInfo objects on each and every InstalledVoice. Below is a code snippet showing how we can accomplish this task:


Next, we need to bind the resulting list to our voiceComboBox.


And finally we need to create the logic inside our button click event to initiate our SpeechSynthesizer


And we are done 😉 Running the application would show as all the installed TTS voice in our machine. One thing to note is that this list is machine dependent and different machines might contain different voices.



Clicking the “Speak!” button should echo our selected voice.


Next time I’ll show you how to export the resulting speech to a wave file. HTH