Friday, November 19, 2010

How Do I Set Textbox Focus in Silverlight4.0?

Here is an example to set focus for a text box in Silverlight application.

In Page.xaml

<UserControl x:Class="TextboxFocusTest.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Loaded="UserControl_Loaded" 
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">        
        <StackPanel Width="150" VerticalAlignment="Center">            
            <TextBox x:Name="UserNameTextBox" IsTabStop="True" />    
        </StackPanel>        
    </Grid>
</UserControl>

In Page.xaml.cs

using System.Windows;
using System.Windows.Controls;
namespace TextboxFocusTest
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
	   System.Windows.Browser.HtmlPage.Plugin.Focus();
           UserNameTextBox.Focus();
        }
    }
}

Happy Coding..Smile

How to Escape Special Characters in XML from C#

I have written a code which escape special characters in XML while posting an XML Request. Here is the sample code sample.

private string EscapeXMLillegalCharacters (string strValue)
{
    return strValue.Replace("&", "&amp;").Replace("'", "&apos;").Replace("\"", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;");
}

Hope this is useful. Happy coding Smile

What are the special characters in XML?

If you use XML with no DTD, then these five character entities are assumed to be pre declared, and you can use them without declaring them:

&lt;
The less-than character (<) starts element markup (the first character of a start-tag or an end-tag).

&amp;
The ampersand character (&) starts entity markup (the first character of a character entity reference).

&gt;
The greater-than character (>) ends a start-tag or an end-tag.

&quot;
The double-quote character (") can be symbolized with this character entity reference when you need to embed a double-quote inside a string which is already double-quoted.

&apos;
The apostrophe or single-quote character (') can be symbolized with this character entity reference when you need to embed a single-quote or apostrophe inside a string which is already single-quoted.

If you are using a DTD then you must declare all the character entities you need to use (if any), including any of the five above that you plan on using (they cease to be pre declared if you use a DTD). If you are using a Schema, you must use the numeric form for all except the five above because Schemas have no way to make character entity declarations.

Tuesday, November 16, 2010

Help full Tools and Converters

Here are some useful tools and converters which are helpful for conversion and compression

.NET Code converters

You can translate any C# code to VB.NET and VB.NET to C#.

http://converter.telerik.com/

http://www.aspalliance.com/aldotnet/examples/translate.aspx

http://www.developerfusion.com/utilities/convertcsharptovb.aspx

I have used first URL from telerik. Its works just great

Compress your CSS

http://www.developerfusion.com/tools/compresscss/

Compress and obfuscate javascript

http://www.developerfusion.com/tools/compressjavascript/

Clear Browser History Through Javascript

If you need to clear the Browser History, after arriving on a particular page (e.g. arriving to Login page after Logout).

Here is the code to do this. If you put this code in Login page, it wont take it to be back page. You need to put this from where you do not want to move back. Here is the code snippet.

<script type="text/javascript">
        window.onload = function () { Clear(); }
        function Clear() {            
            var Backlen = history.length;
            if (Backlen > 0) history.go(-Backlen);
        }
</script>

if you do not want the user to move to the back page, you can do as below. This script needs to be repeated at where you don’t want to do this.

<script type="text/javascript">
       if(window.history.forward(1) != null)
           window.history.forward(1);
</script>

Hope this helps.

Monday, November 15, 2010

Utility : Dell Dock

I have been waiting for some thing like this from Microsoft for so long. I have seen this in Mac and Linux system. But Star dock has build it for Dell. The Dell Dock is a task-based organizer for Dell Laptops or Desktops. It is helpful to the users to sort their software applications into friendly categories, which can be accessed easily from a dock. So that the user can leave the desktop free of clutter. Dell Customers don't have to locate and open a program by application name by rather can locate it by task, like "email & chat", "security", "view photos", "play music", etc..

Here is the screen shot how it look like once you install it

image

Download.

Hope this is useful. I Love it Smile

Thursday, November 11, 2010

How to: Serializable with DAAB

This is how we can convert as Serializable which are written in Data Layer with Enterprise Library DAAB. All you need to do is make the Class and Connection object as Serializable.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Runtime.Serialization;
/// <summary>
/// Summary description for DataLayer
/// </summary>
[Serializable]
public class DataLayer : IDeserializationCallback
{
    [NonSerialized]
    Database db;
    
	public DataLayer()
	{
        db = DatabaseFactory.CreateDatabase("DBConnectionString");        
	}
    public DataTable GetClients()
    {
        DataTable result = new DataTable();
        DbCommand dbcommand = db.GetStoredProcCommand("GetAll_Clients");
        DataSet ds = db.ExecuteDataSet(dbcommand);
        if (ds.Tables.Count > 0)
        {
            result = ds.Tables[0];
            ds = null;
        }
        return result;
    }
    #region IDeserializationCallback Members
    void IDeserializationCallback.OnDeserialization(object sender)
    {
        db = DatabaseFactory.CreateDatabase("DBConnectionString");
    }
    #endregion
}

But you need to make all the data layer classes serializble this way to get the connection right.

Wednesday, November 10, 2010

Windows Azure Services Platform

Windows Azure™ is a cloud services operating system that serves as the development, service hosting and service management environment for the Windows Azure platform. Windows Azure provides developers with on-demand compute and storage to host, scale, and manage web applications on the internet through Microsoft® datacenters.

Windows Azure is a flexible platform that supports multiple languages and integrates with your existing on-premises environment. To build applications and services on Windows Azure, developers can use their existing Microsoft Visual Studio® expertise. In addition, Windows Azure supports popular standards, protocols and languages including SOAP, REST, XML, Java, PHP and Ruby.

Application Scenarios:

Windows Azure is a service that allows developers to run applications and store data on servers owned and operated by Microsoft. These cloud applications can be targeted at businesses, consumers or both. Some examples are:

  • Enterprises that use Windows Azure to run their own line-of-business, batch processing or large-volume computations.
  • An independent software vendor (ISV) that creates a SaaS application targeted towards business users.
  • Perform large-volume storage, batch processing, intense or large-volume computations
  • An ISV that creates a SaaS application targeted towards consumers.

Benefits:

  • Agility: Take advantage of development tools, automated service management and global datacenter presence to respond faster to customer needs, focus on your competitive differentiators, and reach new markets.
  • Efficiency: Windows Azure improves productivity and increases operational efficiency by lowering up-front capital costs. Customers and partners can realize a reduction in Total Cost of Operations of some workloads by up to 30 – 40% over a 3 year period . The consumption based pricing, packages and discounts for partners lower the barrier to entry for cloud services adoption and ensure a predictable IT spend.
  • Focus: Focus on delivering services and value to your customers – and not on managing technology infrastructure. Windows Azure enables you to spend less time on operational hurdles and more time focusing on your competitive differentiators.
  • Simplicity: Utilize your existing skills in familiar languages such as .NET, Java and PHP to create and manage web applications and services.
  • Trustworthy: Enterprise class service backed by a reliable service level agreements and a rich online services experience.

Features:

Windows® Azure serves as the development, run-time, and control environment for the Windows Azure Platform. Windows Azure handles load balancing, resource management and life cycle management of a cloud service based on requirements that the owner of the service established. A developer who wishes to deploy an application to Windows Azure specifies the service topology, including the number of instances to deploy and any configuration settings. Windows Azure deploys the service and manages upgrades and failures to maintain availability.

Storage Services

The Windows Azure storage services provide persistent, durable storage in the cloud. The fundamental storage services include:

  • Binary Large Object (BLOB) service for storing text or binary data
  • Queue service, for reliable, persistent messaging between services
  • Table service, for structured storage that can be queried
  • Windows Azure Drive that allows Windows Azure applications to mount a Page Blob, which is a single volume NTFS VHD. This allows applications to upload/download VHDs via blobs.

The Windows Azure SDK offers a REST API and a managed API for working with the storage services. You may access the storage services from within a service running in Windows Azure or directly over the Internet from any application that can send and receive data over HTTP/HTTPS.

Learn more about Windows Azure on MSDN

Tuesday, November 09, 2010

Happy Birthday, Firefox

Today marks the sixth birthday of the popular web browser Firefox. It was launched on November 9, 2004 as a lightweight and more secure alternative to Internet Explorer 6, which was the dominant browser at the time. Six years later, and Firefox is now the second most widely used browser with steady growth and 31.5% market share according to StatCounter. The next major version of Firefox, Firefox 4, was originally scheduled to be launched by the end of 2010 but was recently delayed into early 2011.

The new version will bring several important improvements like HTML5 support, redesigned user interface, multi-touch functionality, hardware-accelerated HD video and improved support for add-ons through Jetpack

Friday, November 05, 2010

RockMelt, the Social Savvy Browser

RockMelt, a new browser that lives in the cloud and uses Facebook authentication to synchronize a user’s browsing experience across machines, went into limited public beta today.

It was built around the premise that the browser is busted. The thought is that older browsers aren’t made for the way we now use the web, and maybe it’s a solid way of thinking. After all, browsing is a passive activity, and the Internet is increasingly about interaction.

There are some unique concepts here, namely the fact that RockMelt lives in the cloud. This allows your “browser experience” to be, in a way, profiled. Your settings, bookmarks, etc., are all backed up online.

Using Facebook for authentication, your user environment can be replicated anywhere RockMelt is installed. And really, that’s what RockMelt is all about: The user environment.

Users of Google Chrome will feel at home, because RockMelt is built on Chromium, the open source project behind Google’s browser. The major differences are columns running down each side of the browser.

The left side depicts your favorite Facebook contacts. When a contact is listed on the left bar, you’ll be able to quickly initiate Facebook chats with them or post content to their Facebook walls. You can also easily send them e-mails through the seamless contact pop out.

Straddling the right side is your bookmarks — and here’s another area where RockMelt’s cloud is put to clever use. Bookmarks are updated from the cloud, so content is cached and waiting for you when you log on.

All in all, RockMelt is an interesting twist on the browsing experience. The social elements of the browser make for a compelling and streamlined online interaction process. And because it’s powered by Chromium, it not only supports Chromeextensions, it’s guaranteed to support the latest and greatest aspects of the web, like HTML5 and CSS3.