SIGN UP MEMBER LOGIN:    
ARTICLE

Add URL in Navigation Menu in Visual Studio LightSwitch 2011

Posted by Vineet Kumar Saini Articles | VS LightSwitch 2011 February 01, 2012
In this article you will see how to add an URL to the navigation menu of a LightSwitch application.
Reader Level:
Download Files:
 

As you probably know, Visual Studio LightSwitch is a tool provided by Microsoft to build business applications. In this article you will see how to add an URL to the navigation menu of a LightSwitch application.

An URL is a Uniform Resource Locator, it is also known as a web address. When we want to open a website then we write a web address in the address bar in the internet browser. If you want to add any URL in your LightSwitch navigation menu then you can do that.

Step 1 : First of all open Visual Studio LightSwitch->Click on new project->Select LightSwitch->Select LightSwitch application->Write name (AddUrl)->Ok.

image1.png

Step 2 : Right-click on screens->Add screen.

image2.png

Step 3 : Select new data screen->Write screen name (UrlInNavigation)->Select screen data (None)->Ok.

image3.png

Step 4 : Go to Solution Explorer->Click on file view.

image4.png

Step 5 : Right-click on client->Add references.

image5.png

Step 6 : Select System.Windows.Browser->Ok.

image6.png

Step 7 : Expand write code->Select UrlInNavigation_Run->Write code.

image7.png

Code

using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using System.Runtime.InteropServices.Automation;
using System.Windows.Browser;
using Microsoft.LightSwitch.Client;
using Microsoft.LightSwitch.Threading;
namespace LightSwitchApplication
{
    public partial class Application
    {
        partial void UrlInNavigation_Run(ref bool handled)
        {
            // Set handled to 'true' to stop further processing.
            var uri = new Uri("http://www.c-sharpcorner.com/", UriKind.RelativeOrAbsolute);
            Dispatchers.Main.BeginInvoke(() =>
            {
                   if (AutomationFactory.IsAvailable)
                    {
                        var shell = AutomationFactory.CreateObject("Shell.Application");
                        shell.ShellExecute(uri.ToString());
                    }
                   else
                    {
                        throw new InvalidOperationException();
                    }
            });
        }
    }
}

Step 8 : Go to Solution Explorer->Click on logical view.

image8.png

Step 9 : Right click on screens->Select edit screen navigation.

image9.png

Step 10 : Select UrlInNavigation->Clear->Set.

image10.png

Step 11 : Run the application (Press F5). When you will click on URL In Navigation then you will see c-sharpcorner web page will open in your LightSwitch application.

last.png

Conclusion

So in this article you saw how to add an URL of any web page in navigation menu of LightSwitch application.

Some Helpful Resources

Login to add your contents and source code to this article
share this article :
post comment
 

can you give me some code to use me to make email extracter application mail id : sandeepbluesuninfo@gmail.com 9762442668

Posted by sandeep mahamulkar Feb 16, 2012
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor