Thursday, 18 February 2016

How To Create A Master Page And Inherit Pages With It

Master Page

Master Page Is The Template Or Theme Of Our Website Which Is Design With Different client side Languages Like HTML, CSS, JavaScript & AJAX etc. Once We Design The Master Page We Can Inherit Multiple Web Pages From It.

A Web Page Basically Divide Into Main Three Parts:
  • Header
  • Main Body
  • Footer
Header Consist Of  Most Upper Portion Of Website Which Consist Of Main Headings & Drop down Links Of Website E.g:



Main Content Is The Central Part Of The Website Where Data Is Dynamically Changed With Different Pages. Every page has its own Main Content Like E.g: 





Footer Is The Most Lower Part Of Website which Contains the Publishing Details and Links Of References E.g:




Now We Just Design The Master Page and Make A Main Content Place Holder Empty Because Every Page Put Their Own Content In According to their Concern.


Open Visual Studio 2015:


Step 1:

Create A New Project in Web




Step 2:
Choose  Empty Form and click ok



Step 3:

There will be a empty project open & Now Add A Master Page By Right Click on Project And Add New Item.





Step 4:


Now select the Master Page 




Step 5:


Now open Master Page





Step 6:

There Are Two ContentPlaceHolders In The Master Page By Default First For Header And Second For Main Content.
Now Customize Your Page I Take the Kidengarden Templete..

Copy the files and paste into your project





Step 7:


Now Files Are Added In Your Project





Step 8:


Now Add ContentPlaceHolders Where You Want To Change Data Dynamically In Every Page From Inherited Master Page




Step 9:


Now Inherit Page Named Index.aspx Which Have Slider And Main Content Data..



Step 10:


See Its Design...




Step 11:


Now Add Another Page Named Contact.Aspx.....



Step 12:


Design Of Contact Page Here....




In This Way You Can Create Multiple pages Inherit From Master Page...






Monday, 1 February 2016

How To Create Simple Login Form And Nevigate to Registeration Form

Step 1:

Create a New Universal Windows Platform Project and Write Name According to your Project.





Step 2:

Now pick the MainPage.xaml file



Step 3:

Now Inside Main Grid you can make the design According to your Application like this...




<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="0.15*"/>
            <RowDefinition Height="0.85*"/>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Background="LightBlue">
        <TextBlock Name="Login" Text="Login Form" TextAlignment="Center" FontSize="30" FontStyle="Italic" FontWeight="ExtraBlack"></TextBlock>
        </Border>
        <StackPanel x:Name="stackone" Grid.Row="1" >
            <TextBox PlaceholderText="Enter Email" Width="300" Margin="0,50,0,0"></TextBox>
            <TextBox PlaceholderText="Enter Password" Width="300" Margin="0,10,0,0"></TextBox>
            <RelativePanel HorizontalAlignment="Center" Margin="0,10,0,0">
                <Button x:Name="loginbtn" Content="Login" Height="35" Width="65" Click="loginbtn_Click"></Button>
                <Button x:Name="cancelbtn" Content="Cancel" Height="35" Width="65" Margin="10,0,0,0" RelativePanel.RightOf="loginbtn" Click="cancelbtn_Click"></Button>
            </RelativePanel>
         
        </StackPanel>
    </Grid>
</Page>




 Step 4:

Actually Design is here of the code right above...




Step 5:

Now Do This Step Create a New Form Here In This Example I Make Registration Form...




Step 6:

Now make Registration Form Design According to your Application like..



 <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="0.15*" ></RowDefinition>
            <RowDefinition Height="0.85*"></RowDefinition>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Background="Gainsboro">
            <TextBlock Name="Reg" Text="Registration Form" TextAlignment="Center" VerticalAlignment="Center" FontSize="30" FontWeight="Black" FontStyle="Italic"></TextBlock>
        </Border>
        <StackPanel Grid.Row="1">
            <TextBox PlaceholderText="Enter First Name" Width="300" Margin="0,50,0,0"></TextBox>
            <TextBox PlaceholderText="Enter Last Name" Width="300" Margin="0,10,0,0"></TextBox>
            <TextBox PlaceholderText="Enter Email" Width="300" Margin="0,10,0,0"></TextBox>
            <TextBox PlaceholderText="Enter Address" Width="300" Margin="0,10,0,0"></TextBox>
            <RelativePanel x:Name="inside" Grid.Row="1" HorizontalAlignment="Center" Margin="0,20,0,0">
                <Button x:Name="savebtn" Content="Save" Height="50" Width="70"></Button>
                <Button x:Name="cancelbtn" Content="Cancel" Height="50" Width="70" RelativePanel.RightOf="savebtn" Margin="10,0,0,0"></Button>
            </RelativePanel>
        </StackPanel>
     
    </Grid>
</Page>


Step 7:

Actually Design of this Above code is here...





Step 8:

Now We Want To Click On Login and Show Next Page of Registration...
For This Purpose We Go To In MainPage.Xaml .CS File and behind the Login button Event We Add this Line Of Code...



 private void loginbtn_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(Registration));
        }


Step 9:



Now Run The Application and See Your Application and Splash Screen..



Step 10:

Now Login Appear and Click On Button Its Takes You On Registration Form




Click On Login Button...



Monday, 25 January 2016

ASP.NET

What is Asp?

Ans: Active Server pages also known as classic Asp. Asp is a Microsoft server sided technology which helps to make dynamic and user-friendly web pages . It uses different scripting languages to create different dynamic web pages which can run any browser. The web pages are built by using VB script or JavaScript. Asp is implemented through a dynamic-link library (Asp.dll) that is called by the IIS server when a Web page is requested from the server.


What is Asp.Net?

Ans: Asp.Net is a specification developed by Microsoft to create dynamic web applications, web sites, and web services. It is a part of .NET Framework. You can create Asp.Net applications in most of the .Net compatible languages, such as Visual Basic, C#, and J#. The Asp.Net compiles the web pages and provides much better performance than scripting languages, such as VB Script.


What is difference between Asp and Asp.Net?

Ans: The basic difference between Asp and Asp.Net is that Asp is interpreted whereas Asp.Net is compiled. This implies that since Asp uses VB Script therefore, when an Asp page is executed, it is interpreted. On the other hand, Asp.Net uses .Net languages, such as C# and VB.Net, which are compiled to Microsoft Intermediate Language (MSIL).


What is IIS? Why it is used?

Ans: Internet Information Services (IIS) is created by Microsoft to provide Internet-based services to Asp.Net Web applications. It makes your computer to work as a Web server and provides the functionality to develop and deploy Web applications on the server. IIS handles the request and response cycle on the Web server.


What is Platform?

Ans: PHP, JAVA, .NET are examples of platforms or development platforms. This becomes the core of web application. Developers work on different platforms.


What is Framework?

Ans: Framework is set of predefined functions and classes which developer uses for faster development. MVC is a type of framework. Popular examples in PHP would be CodeIgniter and Zend Framework. Framework gives you a set of tools to help you write the code faster and better.


Types of Models in Asp.Net?

Ans:
  •  Web Pages  (Single Pages Model)
  • MVC  (Model View Control)
  • Web forms  (Event Driven Model)
             

Different Approaches in Asp.Net?

Ans:
  • Model First
  • Database First
  • Code First

Model First:

In the model first approach First we create model in a way that all the entities interact directly to each other.

Here the presentation of model...



  • Open Visual Studio
  • Create New Project
  • Select web & click on web project
  • Right click on project and Add New Item 
  • Select Data From Left Side
  • Add ADO.Net Data Model 





  • Select Empty Model






  • Create Model According to your project






  • After Making Model Generate Database Form Model






  • Select the Database






  • Generate Database






  • Here Create Model EDMX File








Database First:

In the database first model we create the tables and then pick these existing tables to map with model.

Here the presentation of model...


  • Open Visual Studio
  • Create New Project
  • Select web & click on web project
  • Right click on project and Add New Item 
  • Select Data From Left Side
  • Select Generate From Database






  • Choose All the Database Tables which you create Already
  • Press Finish Button 





  • Model will be created







Code First:

In code first approach we firstly create classes and then generate the database from classes directly. In this approach we do not need of generate model e.g edmx files.


Here the presentation of  model...



  • First Of All Create Classes



public class Category
   {
      public int CategoryId { get; set; }
      public string Category { get; set; }
      public string Description { get; set; }
   }

   public class Product
   {
      public int ProductId { get; set; }
      public string ProductName { get; set; }
      public float Price { get; set; }
      public int CategoryId { get;set;}
   }


  • Define the DB Context Classes which Came From Drived DBContext



public class SampleContext : DbContext
   {
      public DbSet<Category> Categories { get; set; }
      public DbSet<Product> Products { get; set; }
   }

  • For Performing The CRUD Operations Define the Data Access Class With Proper Functions.



public class SampleDataAccess
   {
      SampleContext  context = new SampleContext();
      public List<Product> GetProducts()
      {
         return (from p in context.Products select p).ToList();
      }
   


  • Add Connection String To The Web.Config File For Access Database


<add name="SampleContext"
   connectionString="datasource=.\sqlexpress;IntegratedSecurity=SSPI;database=SampleDB"
   providerName="System.Data.SqlClient"/>


  • Now Select Object From The Choose Data Source Type Menu And Specify An Id For The Data Source.






  • Select Data Access Class From The List.







  • Select CRUD Operations From Get Product Method. 







  • Tables Will Be Generated.