<< Latest Post

Friday, July 11, 2014

JavaScript or ASP.NET URL Encoding - Dot - Period

I was building an interface to a Google Search Appliance and one of its requirements is to double encode the URL. Interestingly, I noticed that none of the standard JavaScript URL encode functions like encodeURIComponent, encodeURI or escape actually encode the period or dot. Even the asp.net HttpUtility functions like UrlEncode, UrlPathEncode, UrlEncodeUnicode etc. does not encode the period or dot. If the query string data contains a period and if it is not encoded, the Google Search Appliance always returned the wrong data.

Naturally, I googled around and I could not find any reasonable solution to the problem. It seems that the widely accepted solution is to literally replace the period or dot with its ASCII value "%2E".

Even though it is a quick & dirty solution, it actually worked and the Google search appliance returned the valid data!! So, the quick JavaScript workaround is - anystring.replace (".","%2E")




Labels: , , , , , , , , , , , ,





Thursday, July 03, 2014

Windows Phone 8 - Global App Bar across all your pages


If you want to have a same App Bar across all the pages of your Windows Phone 8 app, it could be achieved by placing the code in the app level file App.xaml similar to Master Page or Global.asax.

Here are the steps to display the global app bar -

  • Add the app bar markup to the App.xaml file.

         App.xaml

          <shell:ApplicationBar x:Key="RootAppBar" IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Your Text" Click="YourText_Click">
            </shell:ApplicationBarMenuItem>
           </shell:ApplicationBar.MenuItems>
          </shell:ApplicationBar>

  • If the menu item has a click event, then add the click event code to App.xaml.cs file. 
           void YourText_Click(object sender, EventArgs e)
           {
                // Write your click event code here.
           }

  • Finally, add reference to the app bar in the pages that needed an app bar. It can be done by adding ApplicationBar property and pointing it to a static resource in the global page markup. For e.g. if you would like to add a app bar on the main page, see the sample below,
        MainPage.xaml

          <phone:PhoneApplicationPage 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             FontFamily="{StaticResource PhoneFontFamilyNormal}"
             FontSize="{StaticResource PhoneFontSizeNormal}"
             Foreground="{StaticResource PhoneForegroundBrush}"
            SupportedOrientations="Portrait" Orientation="Portrait"
            shell:SystemTray.IsVisible="True"
            ApplicationBar="{StaticResource RootAppBar}">


Labels: , , , , , , , , , , , , , , , , , ,