Home Page in LightSwitch


Introduction

  • A Home page is a starting page of any web browser.
  • A Home page contain the information of a website.
  • There may be many links in a Home page to other part of web site.
  • The initial page which WWW browser shows? covering page of the web site? or web pages on the whole?
  • For a Web user, the home page is the first Web page that is displayed after starting a Web browser.
  • For a Web site developer, a home page is the first page presented when a user selects a site or presence on the World Wide Web. It most often refers to the initial or main web page of a web site, sometimes called the front page. (http://searchsoa.techtarget.com/definition/home-page)
     

Home.gif

Step by step solution

Step 1: Open Visual Studio LightSwitch->File->New->Project.

1st.gif

Step 2: Go to properties->Access Control->Mark Granted for debug.

image1.gif

Step 3: Run application (Press F5)->Click +.gif sign in user section->Fill data->Save.

image2.gif

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

image4.gif

Step 5: Select New Data Screen->Write name of screen (Homepage)->Ok.

image5.gif

Step 6: Add data item->Select local property->Type (string)->Write name (Name)->Ok.

image6.gif

Step 7: Repeat above process 3 or 4 times, with Name, FullName, IsAuthenticated, AuthenticationType.

image7.gif

Step 8: Right click on Command Bar->Delete.

image8.gif

Step 9: Move Name from HomePage to Command Bar, Likes below image.

image9.gif

Step 10: Add->Select FullName, IsAuthenticated, AuthenticationType.

image10.gif

Step 11: Go to write code->Select HomePage_Created->write the below code.

image12.gif

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;
namespace
LightSwitchApplication
{
    public partial class HomePage
    {
        partial void HomePage_Created()
        {
            Microsoft.LightSwitch.Security.IUser currentUser = this.Application.User;
            if (currentUser != null)
            {
                this.Name = currentUser.Name;
                this.FullName = currentUser.FullName;
                this.IsAuthenticated = currentUser.IsAuthenticated.ToString();
                this.AuthenticationType = currentUser.AuthenticationType.ToString();
            }
 
        }
    }
}

Step 13: Go to properties->Screen Navigation->Select Home Page->set.

image15.gif

Step 14: Run application (Press F5)->Go to Design screen.

image16.gif

Step 15: Select Label in the Name, FullName, IsAuthenticated, AuthenticationType->Save.

image17.gif

Step 16: Now Name, FullName, IsAuthenticated, AuthenticationType will show in the label.

image18.gif

Summary

So a Home page is the front page of a website which contains information about the website. Every website contains a Home Page. 


Similar Articles