-->

Wednesday, October 28, 2015

WPF menu bar with dockpanel | additem | Image | Icon | Checkbox | Click event

In this article, I will teach you, how to add WPF menu bar at top position in window, Add items in it, add image as icon in it, also handle click event on each items of it. I explained, how to add items with underline.

<Window x:Class="WpfApplication5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<DockPanel>
Title="MainWindow" Height="350" Width="525"> <Grid> <Menu DockPanel.Dock="Top">
<MenuItem Header=" second child"/>
<MenuItem Header="_First Parent"> <MenuItem Header="New" Command="New"/>
</MenuItem.Icon>
<MenuItem Header="Third child with image"> <MenuItem.Icon> <Image Source="mango.png"/>
<MenuItem Header="Second first child" IsCheckable="True" IsChecked="True" Click="MenuItem_Click"/>
</MenuItem> </MenuItem> <MenuItem Header="Second Parent"> </MenuItem> </Menu> </DockPanel>
</Window>
</Grid>

The above-mentioned XAML code define, a menu control inside in DockPanel control at top position. The first item in the menu works as container. In the first menu item, we have three child items. First child item contains shortcut key by using command attribute. Second child item appears as simple text, last item contain image. Similarly add another menu item in the menu control for making second parent item with click event. 



  private void MenuItem_Click(object sender, RoutedEventArgs e)  
     {  
       MessageBox.Show("second parent first child clicked");  
     }  
When, I press child item of second parent item then appear a message box on the screen.
Code generates the following output:

WPF menu bar with dockpanel | additem | Image | Icon | Checkbox | Click event

Example of Login form in WPF

Today, I will teach you, how to design login form in WPF. Also, I will teach you, how it will work. In this example, I will take two text boxes, two Text Blocks and one button control from ToolBox. Now, create a database table with some following fields:

 CREATE TABLE [dbo].[users] (  
   [Id]    INT      NOT NULL IDENTITY,  
   [username] NVARCHAR (50) NULL,  
   [password] NVARCHAR (50) NULL,  
   PRIMARY KEY CLUSTERED ([Id] ASC)  
 );  

In this database table, I have three column, first column is automatic incremented by one.

 <Window x:Class="WpfApplication5.additemwpflistview"  
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
     Title="additemwpflistview" Height="300" Width="300">  
   <Grid>  
     <TextBlock HorizontalAlignment="Left" Margin="10,41,0,0" TextWrapping="Wrap" Text="UserName" VerticalAlignment="Top"/>  
     <TextBox Name="t1" HorizontalAlignment="Left" Height="23" Margin="94,41,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="120"/>  
     <TextBlock HorizontalAlignment="Left" Margin="15,91,0,0" TextWrapping="Wrap" Text="Password" VerticalAlignment="Top"/>  
     <TextBox Name="t2" HorizontalAlignment="Left" Height="23" Margin="94,84,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="120"/>  
     <Button Content="Login" HorizontalAlignment="Left" Margin="94,130,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>  
   </Grid>  
 </Window>  

Note: Before doing all such things, must to add EDMX file in the project.


  private void Button_Click(object sender, RoutedEventArgs e)  
     {  
       DatabaseEntities dbe = new DatabaseEntities();  
       if(t1.Text!= string.Empty || t2.Text!=string.Empty)  
       {  
         var users = dbe.users.FirstOrDefault(a => a.username.Equals(t1.Text));  
         if(users!=null)  
         {  
           if(users.password.Equals(t2.Text))  
           {  
             WPFListview l1 = new WPFListview();  
             l1.ShowDialog();  
           }  
         }  
       }  
     }  

Code generates the following output:

Example of Login form in WPF


Monday, October 26, 2015

WPF Listview formatting, styling

In this article, I will teach you, how to change Background color, foreground color, font style, and many more things. I explained already many more things about WPF Listview like
  1. How to add items in it using XAML code
  2. How to bind the WPF Listview.view from Gridview.
  3. WPF Listview binding from EDMX file 
  4. Binding it with List of string type.
Also covered many more articles, which is related to styling and formatting. You can see my video article for Learn WPF styling using static as well as dynamic. Today, I will put some styles in XAML code. Let's see

   <ListView Name="list1" HorizontalAlignment="Left" VerticalAlignment="Top">  
       <ListViewItem FontFamily="Times New Roman" FontSize="15" Foreground="Red" Background="Green" BorderBrush="AliceBlue" BorderThickness="2">Apple</ListViewItem>  
       <ListViewItem FontSize="16" Foreground="Green" Background="orange" BorderBrush="AliceBlue" BorderThickness="2">Orange</ListViewItem>  
       <ListViewItem FontSize="17" Foreground="Red" Background="White" BorderBrush="AliceBlue" BorderThickness="2">Pea</ListViewItem>  
       <ListBoxItem>  
         </ListBoxItem>  
     </ListView>  

Code generates the following output

WPF Listview formatting, styling

Sunday, October 25, 2015

WPF Listview with ItemTemplate binding using EDMX file

In this article, I will teach you, how to bind WPF Listview with ItemTemplate using EDMX file. Also, I will give you an example of it. So far we have discussed basics of WPF Listview control. Let's see, what's are covered about WPF:

  1. WPF Listview binding with Gridview cell template using EDMX file
  2. WPF LISTVIEW BINDING USING EDMX FILE
  3. wpf listview bind with list of string type
Let's see the example of this example:

 <Window x:Class="WpfApplication5.MainWindow"  
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
     Title="MainWindow" Height="350" Width="525">  
   <Grid>  
     <ListView Name="list1">  
       <ListView.ItemTemplate>  
         <DataTemplate>  
           <WrapPanel>  
             <TextBlock Text="Id="/>  
             <TextBlock Text="{Binding Id}"/>  
             <TextBlock Text=","/>  
             <TextBlock Text="Name="/>  
             <TextBlock Text="{Binding Emp_Name}"/>  
           </WrapPanel>  
         </DataTemplate>  
       </ListView.ItemTemplate>  
     </ListView>  
   </Grid>  
 </Window>  

Before doing code in code-behind file, add EDMX file in project.

  public partial class MainWindow : Window  
   {  
     public MainWindow()  
     {  
       InitializeComponent();  
       loaditemTemplate();  
     }  
     private void loaditemTemplate()  
     {  
       DatabaseEntities dbe = new DatabaseEntities();  
       list1.ItemsSource = dbe.Employees.ToList();  
     }  
   }  

Code generates the following output

WPF Listview with ItemTemplate binding using EDMX file

Saturday, October 24, 2015

First 3 WPF videos, start your learning

I will give you a WPF videos series. If you watch each then you do start your career with WPF. Through WPF videos, you can design light weight application. Let's start step by step. In first video you learn about basics of WPF projects, let's see



In this video, I will teach you many more things about WPF start like

  1. How to start Visual Studio for WPF application.
  2. Create new project for WPF, select C# language in left pane, select WPF application in middle pane.
  3. First-page name of the default window is MainWindow.xaml. It contains default WPF Grid control.
  4. Add a TextBlock with Text property inside WPF grid.
  5. Learn, How to run WPF application.
Now, come to next video of WPF videos series. First of all, I will teach you about WPF panels. So, here, I share you a video of stack panel.

Check it, what is inside. Drag WPF stack panel control from ToolBox, drop it in Window. When we add it in Window then XAML automatically update with stack panel code. Here, we have HorizontalAlignment=left, Height="100", width="100", verticalAlignement="Top".  You can resize it by all corners using design window. Now, you can add buttons and other controls inside stack panel. A button control has content property, which is used as a label. By using orientation property, we can set controls alignment either horizontally and vertically. By using this video also, I explain you, how to add image in stack panel. Stack panel contains another stack panel. Now, come to next video of WPF videos series.

Grid panel is also a container. It has two things that are RowDefinition and ColumnDefinition. WPF grid is the most popular control in presentation foundation. By using this, we can add controls in it a specific cell  of Rows and columns. If, your controls are outside from grid then you can place it in WPF Grid, watch this video and learn, how to place control inside WPF Grid.

Friday, October 23, 2015

WPF Listview items with images

WPF ListView is a container of other single controls. I mean to say that you can put other single control in it. Other controls considered as a Listview item. You can put only simple single string or control like TextBlock. Lets to check the demo of this line.

1:     <ListView>  
2:        <ListViewItem>  
3:          <TextBlock Text="Fruits"/>  
4:        </ListViewItem>  
5:        <ListViewItem>  
6:          Vegetables  
7:        </ListViewItem>  
8:      </ListView>  

In this code, we have both string as well control. You can take other containers in it like StackPanel etc. as a ListView Item. In previous example, i taken Gridview control as view of Listview. Now, i will take image with Text in it as a single WPF Listview item.

1:  <ListView>  
2:        <ListViewItem>  
3:          <StackPanel Orientation="Horizontal">  
4:            <Image Source="apple.png"/>  
5:            <TextBlock Text="Apple"/>  
6:          </StackPanel>         
7:        </ListViewItem>  
8:        <ListViewItem>  
9:          <StackPanel Orientation="Horizontal">  
10:            <Image Source="mango.png"/>  
11:            <TextBlock Text="mango"/>  
12:          </StackPanel>  
13:        </ListViewItem>  
14:        <ListViewItem>  
15:          <StackPanel Orientation="Horizontal">  
16:            <Image Source="grapes.png"/>  
17:            <TextBlock Text="grapes"/>  
18:          </StackPanel>  
19:        </ListViewItem>  
20:      </ListView>  
Copy this code and paste into your WPF window, before doing this, please add three image into your project,. These three images names are apple.png, mango.png and grapes.png.

WPF Listview items with images


ASP.NET FILEUPLOAD CONTROL CHANGE BACKGROUND COLOR USING CODE

Each control in ASP.NET ToolBox of visual studio, treat as a class. Property window shows the behavior of their controls also contains some common property, such as back-color, border color etc. Now in this article, we will take a simple example to change the background color of ASP.NET file upload control.

Description
I explained, ASP.NET FILEUPLOAD CONTROL change border color, File upload control enable/disable

Source code




 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="fileupload_backcolor.aspx.cs" Inherits="fileupload_backcolor" %>  
 <!DOCTYPE html>  
 <html xmlns="http://www.w3.org/1999/xhtml">  
 <head runat="server">  
   <title></title>  
 </head>  
 <body>  
   <form id="form1" runat="server">  
   <div>  
     Enter Alpha color :  
     <asp:TextBox ID="TextBox1" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     Enter Red Color :  
     <asp:TextBox ID="TextBox2" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     Enter Green Color:  
     <asp:TextBox ID="TextBox3" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     Enter Blue Color&nbsp;&nbsp; :  
     <asp:TextBox ID="TextBox4" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     <br />  
     <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Change Fileupload background color" Width="260px" />  
     <br />  
     <br />  
   </div>  
     <asp:FileUpload ID="FileUpload1" runat="server" Height="51px" Width="311px" />  
   </form>  
 </body>  
 </html>  

Code Behind Code

 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Web;  
 using System.Web.UI;  
 using System.Web.UI.WebControls;  
 public partial class fileupload_backcolor : System.Web.UI.Page  
 {  
   protected void Page_Load(object sender, EventArgs e)  
   {  
   }  
   protected void Button1_Click(object sender, EventArgs e)  
   {  
     int alpha = int.Parse(TextBox1 .Text);  
     int red = int.Parse(TextBox2.Text);  
     int green = int.Parse(TextBox3.Text);  
     int blue = int.Parse(TextBox4.Text);  
     FileUpload1.BackColor = System.Drawing.Color.FromArgb(alpha, red, green, blue);  
   }  
 }  

Code Generate the following output

programmatically change background color of fileupload control in ASP.NET

programmatically change background color of fileupload control in ASP.NET

In this example, we are taking four textboxes, one button, one file upload control. Using text box we can input the color code value and pass these values into the FromArgb ( ) method. This example is basically designed for users, who want to change the color of file upload control at run time.

Thursday, October 22, 2015

WPF Listview binding with Gridview cell template using EDMX file

Good evening, welcome to WPF programming. I already explained, how to bind WPF listview from string type list also explained binding it with database table using EDMX file. In this article, I will give you an example of cell template of Gridview, which is inside in WPF Listview. You can say, I will update previous WPF listview article. If you want to customize your Gridview cell in WPF Listview control then use cell template.


Note: Before doing this task, read previous

You need to change only XAML file without any changes in code behind code. The previous XAML code is:

<Grid>
<ListView Name="listgrid">
<ListView.View>  
<GridView>  
<GridViewColumn Header="Id" DisplayMemberBinding="{Binding Id}"/>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Emp_Name}"/>
</GridView> </ListView.View> </ListView>
</Grid>

Now, replace it with below-mentioned code

<Grid>
<ListView Name="listgrid">
<ListView.View>
 <GridView> 
<GridViewColumn Header="Id" DisplayMemberBinding="{Binding Id}"/>
<GridViewColumn Header="Name">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Emp_Name}" FontWeight="Bold"/>
</DataTemplate> 
</GridViewColumn.CellTemplate> 
</GridViewColumn>
</GridView> </ListView.View>
</Grid>
</ListView>

Now, codes generate the following output:

WPF Listview binding with Gridview cell template using EDMX file

ASP.NET fileupload control change border color Programmatically

Each control in tools of visual studio, treat as a class. Property window shows the behavior of their controls also contains some common property, such as back-color, border color etc. Now in this article, we will take a simple example to change the border color with border style of ASP.NET FILEUPLOAD control. I explained, How to use file upload, enable/disable file upload and many more properties.

Source code


 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="fileupload_backcolor.aspx.cs" Inherits="fileupload_backcolor" %>  
 <!DOCTYPE html>  
 <html xmlns="http://www.w3.org/1999/xhtml">  
 <head runat="server">  
   <title></title>  
 </head>  
 <body>  
   <form id="form1" runat="server">  
   <div>  
     Enter Alpha color :  
     <asp:TextBox ID="TextBox1" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     Enter Red Color :&nbsp;&nbsp;  
     <asp:TextBox ID="TextBox2" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     Enter Green Color:  
     <asp:TextBox ID="TextBox3" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     Enter Blue Color&nbsp;&nbsp; :  
     <asp:TextBox ID="TextBox4" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     <br />  
     <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Change Fileupload background color" Width="260px" />  
     <br />  
     <br />  
   </div>  
     <asp:FileUpload ID="FileUpload1" runat="server" Height="51px" Width="311px" />  
   </form>  
 </body>  
 </html>  


code behind

 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Web;  
 using System.Web.UI;  
 using System.Web.UI.WebControls;  
 public partial class fileupload_backcolor : System.Web.UI.Page  
 {  
   protected void Page_Load(object sender, EventArgs e)  
   {  
   }  
   protected void Button1_Click(object sender, EventArgs e)  
   {  
     int alpha = int.Parse(TextBox1 .Text);  
     int red = int.Parse(TextBox2.Text);  
     int green = int.Parse(TextBox3.Text);  
     int blue = int.Parse(TextBox4.Text);  
     FileUpload1.BorderColor = System.Drawing.Color.FromArgb(alpha, red, green, blue);  
     FileUpload1.BorderStyle = BorderStyle.Solid;  
     FileUpload1.BorderWidth = 2;  
   }  
 }  

Code Generates the following output

Programmatically change border color of fileupload control in ASP.NET

Programmatically change border color of fileupload control in ASP.NET

In this example, we are taking four textboxes, one button, one file upload control. Using text box we can input the color code value, pass these values in the FromArgb ( ) method as an argument. This example is basically designed for users, who want to change the border color of ASP.NET FILEUPLOAD control at run time.

ASP.NET Fileupload control enable/disable programmatically

Enable property defines the working mode of asp.net file upload control. It has two boolean value first one is true and second one is false. If you set true for this then control work properly otherwise control doesn't work, I mean to say that fileupload appear on screen but will not work as input control. If you want to set this property during compile time, must add attribute inside the tag. Like

  <asp:FileUpload ID="FileUpload1" runat="server" Enabled="False" />  

    true is the default value for this. Now take a simple example to change the value at run time.

Source code


 <form id="form1" runat="server">  
  <div>  
     <asp:FileUpload ID="FileUpload1" runat="server" Enabled="False" />  
     <br />  
     <br />  
     <asp:Button ID="Button1" runat="server" Text="Enable/Disable" OnClick="Button1_Click" />  
     <br />  
     <br />  
     <asp:Label ID="Label1" runat="server" Text=""></asp:Label>  
   </div>  
   </form>  

Code Behind 


 <script runat="server">  
   protected void Button1_Click(object sender, EventArgs e)  
   {  
     if (FileUpload1.Enabled == true)  
     {  
Label1.Text = "file upload control is enabled "; 
FileUpload1.Enabled = false; } else { Label1.Text = "file upload control is disabled "; FileUpload1.Enabled = true; } } </script>

Code Generate the following output

Fileupload control  disable programmatically in ASP.NET

Fileupload control enable  programmatically in ASP.NET
When we press the browse button then we know that it is working or not. Above mentioned snap define this. In first, snap you can see that open file dialog doesn't appear but in second snap its appear, so in second, snap it is working.

Default Listing with Insert and Update in MVC 4

MVC 4 provides simple listing procedure through which developer can create CRUD actions for a database table. Awesome thing is developer don’t need to write a single line of code and will complete the task.
We have added new table Category and updated edmx file in earlier article. Now we will create CRUD actions and their views with default MVC 4 structure. We have created empty controller without using any default action but now we will add a controller with all the default actions.
Follow the procedure for creating a controller and in “Add Controller” window name the controller as CategoryController and select the options as selected in the following screenshot and click on Add button:
CategoryController and select the options as selected

This window is prompting for your context class (inherited from DbContext or may be your edmx entities name) file and the model name for which these actions will be created.
After clicking on Add button, it will add a controller with following 5 actions and corresponding views. Those views are not created on the root, but MVC 4 will create those views under new folder with the same name as controller.
  • Create
  • Delete
  • Detail
  • Edit
  • Index
Run your project and go to specified controller/Index page, it will load all the categories your database have. Have a look on the below screenshot, with three records each having three action-link i.e. Edit, Details and Delete. Beside these individual action links this table structure also have Create New action on the top through which it will redirect to another view.

So we have saved lot of time that may waste to write the code for all these actions and also for creating their views. This MVC 4 feature is very simple to use and we can create more control for each table. Developer can customize these actions or their views as per their requirements.
Some developer don’t need all these views or maybe they want to enable all these actions on the single page. In next article we will create listing page for our own and write some line of code for table structure.

WPF LISTVIEW BINDING USING EDMX FILE

In previous WPF listview article, I explained, how to bind listview from List of string type. In this article, I will explain you, how to bind listview using EDMX file. We all know about powerful features of  WPF listview i.e Gridview. Lets, take an example of it.

  <Grid>  
     <ListView Name="listgrid">  
       <ListView.View>  
         <GridView>  
           <GridViewColumn Header="Id" DisplayMemberBinding="{Binding Id}"/>  
           <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Emp_Name}"/>  
         </GridView>          
       </ListView.View>     
     </ListView>  
   </Grid>  

In the mentioned code, Gridview is a view of WPF Listview with two columns that are Id and name. Here, DisplayMemberBinding is the property of GridviewColumn, which is used to bind listview columns from field of model class.

  public partial class MainWindow : Window  
   {  
     public MainWindow()  
     {  
       InitializeComponent();  
       loadlistview();  
     }  
     private void loadlistview()  
     {  
       DatabaseEntities dbe = new DatabaseEntities();  
       listgrid.ItemsSource = dbe.Employees.ToList();  
     }  
   }  

Here, DatabaseEntities, context class in EDMX model, also Employees is the public property in DataContext class. Learn How to add EDMX file with database file.
Now, code generate the following output:

WPF LISTVIEW BINDING USING EDMX FILE

ASP.NET FILEUPLOAD CONTROL INSERT IMAGE INTO DATABASE

Introduction

First of all, I would like to thank all of the readers who have read my previous articles. What a great support I have got from you people. By using ASP.NET File upload control, we can easily insert images into Table or you can say that we can create image gallery projects. With the help of JQuery, we put some dynamic effects like upload multiple files one by one. you can also do by JQuery to create button work as File upload. I really felt great when article Bind GridView was displayed on this blog page. Following are the articles that I have written so far for beginners as well as developers.



Follow some steps for inserting Images into database using asp.net fileupload control.

STEP-1 : Create Database Table

HOW TO INSERT IMAGE INTO DATABASE



STEP-2: Drag asp.net fileupload control from ToolBox and Drop it in Design window.


  <form id="form1" runat="server">  
   <div>  
     <asp:FileUpload ID="FileUpload1" runat="server" /><BR />  
     <asp:Button ID="Button1" runat="server" Text="Submit" />  
     <br />  
     <br />  
     <asp:Label ID="Result" runat="server"></asp:Label>  
   </div>  
   </form>  

fileuploadcontrol
STEP 3: Make a new directory in website folder name as "upload".
STEP 4:  Double click on submit button and raise click event.

 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Web;  
 using System.Web.UI;  
 using System.Web.UI.WebControls;  
 using System.Data.SqlClient;  
 using System.Configuration;  
 using System.Data;  
 public partial class FILEUPLOAD : System.Web.UI.Page  
 {  
   protected void Page_Load(object sender, EventArgs e)  
   {  
   }  
   protected void Button1_Click(object sender, EventArgs e)  
   {  
     string imagedata = string.Empty;  
     if (FileUpload1.HasFile)  
     {  
       FileUpload1.SaveAs(Server.MapPath("~/upload/" + FileUpload1.FileName));  
       imagedata = "~/upload/" + FileUpload1.FileName;  
     }  
     using (SqlConnection con = new SqlConnection())  
     {  
       con.ConnectionString =ConfigurationManager .ConnectionStrings ["ConnectionString"].ToString ();  
       con.Open ();  
       using (SqlCommand cmd=new SqlCommand ())  
       {  
         cmd.Parameters.AddWithValue("@ur", imagedata);  
         cmd.CommandText ="insert into imagedata(url) values(@ur)";  
         cmd.Connection =con;  
         if (string.IsNullOrEmpty(imagedata))  
         {  
           Result.Text = "choose right image";  
         }  
         else  
         {  
           int a = cmd.ExecuteNonQuery();  
           if (a > 0)  
             Result.Text = "data inserted";  
           else  
             Result.Text = "failed";  
         }  
       }  
     }  
   }  
 }  

Output of the program
How to insert image into database using file upload control

How to insert image into database using file upload control
Here, first to insert images in website folder also get the File path during fileupload. Now, insert the file into Table as like Text. 

Update Edmx When Database Changes in MVC 4

MVC 4: Update Edmx is to make the model as same as the database through which it created. Whatever changes made with the database will not reflect in the Model to perform CURD functions. Suppose we have added a new table with SQL server management studio and want to insert/update some entries with that table using code part. After creating object of database context, notice that we don’t have an instance for that newly added table. To resolve this issue we have to update our edmx using Update Model Wizard as described in this article.

Create new table Category in the same database added earlier and use basic columns like id, name, description, isActive. Open our visual studio project and check that this table have not any existence yet. Open edmx file, right click on the blank space and click on Update Model from Database.

Update Model from Database





  An Update Model wizard will open with options to add tables, views and stored procedures. We have added only a table so expand “Tables” node and select “Categories”. Leave remaining options as they are and click finish.


expand “Tables” node and select “Categories


 After finishing it will reload and will add newly added table, check the edmx file and there are two tables Employee and Categories as shown in below image.

check the edmx file


This update model wizard does following in MVC 4:
  • If a table removed from database, it will remove from the model also and update mapping details.
  • If table has been added, it will insert new object in the existing model and update mapping details.
  • Any modification in the object, this wizard will update the model like to add/remove columns.

Wednesday, October 21, 2015

Top 10 asp.net forums

Asp.net forums: It mean provide help related to asp.net code and many more things like presentation related, business logic related etc. asp.net support many languages like c#, f#, vb etc. These languages are interoperable so all mentioned forums are working in all languages.

(Top-1)asp.net forums: This is related to many more things like tutorials, articles, learning skills, asp.net forums etc. Forums working on these following topics:

  1. Getting started: general awareness of asp.net.
  2. web forms:   Server controls, events, validation, master pages, themes, web parts, personalization, etc.
  3. Web Forms Data Controls : Data-bound controls such as the GridView, DataGrid, DataList, FormView, DetailsView, Repeater, and Microsoft Chart.
  4. MVC: Discussions regarding ASP.NET Model-View-Controller (MVC).
Alexa Traffic Rank




(Top-2)stack overflow: This is related to various technologies like asp.net, php, javascript, c++, java, mysql, css, html, python etc. Put your thread related to tag.

stack overflow alexa rank


(Top-3)c-sharpcorner : Uncategorized asp.net forums, in this you can put your thread and get answers from other developers of people.

Alexa rank: Global rank- 4864

(Top-4) asp.net forums : Simple categories forum in different technologies like DOTNET Framework, asp.net, Database, html,css and java script. First to register in it and put your thread in specific category.

Alexa Rank : Global rank - 83681

(Top-5) newly start forum: This forum is newly started, if you join this then you get golden membership. It categories in differeent sub categories like ASP.NET, AJAX, WEB FORMS, MVC, WEB SERVICE, JQUERY.

Alexa rank : Global rank - 6,20,230

(Top-6) dotnet spider : Before posting any thread in it, make register, register button available in top right corner. Fill all reguired fields, do login by their username and psasword. If you want to post your thread here then select forum from navigation, select respective forum.

Alexa rank : Global rank - 55, 428

(Top-7)Dotnet funda: Similarly in this, we can put thread for other users. Joining is so simple and sweet, first to register, confirm email by your mail box, login by their username and password. Select category under forum tab.

Alexa rank : Global rank- 27,602

(Top-8) Tutorialized Forum: You can start threading by your errors/doubts. Interesting thing in this forum, if you are new user for this forums then you can not allow to submit url.

Alexa rank:  Global rank - 82,259

(Top-9) Discountasp.net : Discount asp.net forums share current news and updates which is related to asp.net. Provide various services to the users like getting started, hosting services, general trubleshooting, control panel etc. Before reply to any thread, you have full permissions.

Alexa rank:  Global rank- 99,677

(Top-10) developer fusion :  This forum contain both licence and open source contents, i mean to say catogries realted to all technology like java, asp.net etc.

Alexa rank : Global rank- 71,191

Refactoring in visual studio 2013,2015

Refactoring, change the internal structure of the code without any changes in behavior/outer structure. By using visual studio plugins, you can do the following refactoring in the visual studio code. The most popular and powerful refactoring plugin/extension in visual studio is visual assist. By using it, we can do some following tasks:

  • Extract method refactoring: By using visual studio we can create new methods for existing code, I want to say that if you have a code in a method, you want to break it in different segments/methods then you can use extract method like Suppose your code look like
   public class Class1  
   {  
     public void display()  
     {  
       int a=10;  
       int b=20;  
       Console.WriteLine(a + b);  
     }  
   }  

Select the code fragment you want to extract:

  int a=10;  
       int b=20;   

Right click on selected text, Refactor--> Extract Method..., appear new window.

Extract method window in visual studio

After pressing the "ok" button, your code look like

  public class Class1  
   {  
     public void display()  
     {  
       int a;  
       int b;  
       NewMethod(out a, out b);  
       Console.WriteLine(Convert.ToString(a+b));  
     }  
     private static void NewMethod(out int a, out int b)  
     {  
       a = 10;  
       b = 20;  
     }  
   }  

  • Change class name also the file name: If you want to change class name after creating code then you can do this by replacing. But, file name doesn't change. So, try visual assist to change the class name, constructor name, and file name.    
Right click on class name, select Refactor(VA)--Rename to change the class name also file name.


After do this, your code and file:

Change class name also the file name

Tuesday, October 20, 2015

VISUAL STUDIO DESIGN GAMES USING UNITY PLUGINS

Microsoft and many more product based companies provides some extensions for visual studio. Behind the scene, the main purpose of them, they want to enhance the features of visual studio. Similarly, UNITY software is a type of extension, which is used for design games in visual studio. UNITY provides you to make platform independent games, i mean, you can run your games data in 21 platforms. Also provides many more features like:
  1. You can design your games either in 2D and 3D.
  2. Debug your game code using break point in visual studio.
  3. You can put your logics in UNITY game by using c#, which is userfriendly for you.
  4. Check error in error list of visual studio. 

How to download it: Download it by using official sites, but i recommended this path, Through this you can download other things. Download UnityDownloadAssistant-5.2.1f1.exe, start it by using double click. Below mentioned Progress snap  of downloading. 

unity download installer

In the next article i will show you how to start screen of unity, how to start codes in it and many more things.

Monday, October 19, 2015

Design beautiful web forms in any technology

Good morning, i am jacob, Today i have to share some post which is related to design beautiful web forms in asp.net. If you want to design web forms in asp.net then you need to learn some basic technologies like HTML, CSS, Photoshop, JQuery etc. Here, i will tech you about these technologies one by one using some web forms article. so, lets start, Following these steps to design beautiful we forms:
(Task-1)Before anything doing, must to rough stretch your website : Suppose you want to design 20 pages website then  you need 20 pages of note book. Now, stretch each web site page into your notebook. Suppose i have to design first page in my note book that is:

design beautiful web forms

Similarly do for all remaining pages. Now, your first task is completed.

(Task-2)Fill colors in stretched design: Now, come to second task that is fill colors, For beautiful web forms, must to fill different colors in the page by using color pens.

(Task-3)Design your pages by using Photoshop: By using Photoshop, you can feel exact look of your theme. So, Read some how to: articles about Photoshop by using googling. 

(Task-4)Now, start to design beautiful web forms in HTML from first page of your stretch/Photoshop page: Here, i have use web forms design in asp.net, so you need to read some article about asp.net master page. By using master page you can design your layout of all beautiful web forms.
Read more article about master page : need of master page and themes in asp.net

(Task-5) Fill colors and make responsive your design by using CSS3: if you want to design responsive and beautiful web forms then you need to learn CSS(Cascading Style Sheet). Here, i have demo of style sheet.

(Task-6) Put some Dynamic effects using JQuery into your web forms: If you have some pages which is related to login/register then use JQuery to put some dynamic effects like shadow, popups etc. I have some examples, which is related to dynamic effects like:
Dynamic effects using JQuery :  Show login form in popup using JQuery.

Saturday, October 17, 2015

wpf listview bind with list of string type

As we all know the wpf listview is inherited class of listbox and have almost all the properties of listbox. We have learnt listbox binding with string list in our earlier post. In this article we bind the listview with the same string list.

Just place a wpf listview having only name property, because we have to access that wpf listview in our code behind file. We can also use height and width property of the listview, if the data items are of lengthy string.
<ListView>
<ListView.Name>listView</ListView.Name>
</ListView>

Now use the same list of string as in previous post i.e.
List<string> strList = new List<string>();
strList.Add("London");
strList.Add("Italy");
strList.Add("California");
strList.Add("France");
listView.ItemsSource = strList;

Now look out the last statement, it will set the item source of the wpf listview as this string list. When we run the project it will show a listview with four items:

Bind listview with string list in WPF C#


To get selected item the same procedure will follow as in listview bind with grid resource.

jquery button created dynamically

Introduction
In this article, i will show you how to create jquery button dynamically. Example of dynamically created button using jquery. In this example, create a input tag with their attributes by using jquery. Now, after this you can append it in division.



<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>JQuery Button Created Dynamically</title>
    <script src="Scripts/jquery-1.10.2.js"></script>
  <script>
      $(document).ready(function () {
          var $bt=$('<input/>').attr({type:'button',name:'mybutton',value:'Dynamic Button'});
          $("#div1").append($bt);


      })

  </script>

</head>
<body>
 <div id="div1"></div>

</body>
</html>

Friday, October 16, 2015

Query String in web forms asp.net c#

Introduction

Query String in web forms asp.net is very important if you have a shopping products. Through this  article we will show you how to use Query String in web forms asp.net also you can say i will provide you an example of it.  If we want to pass control or variable value from one form to another form then we can use QueryString . There are many options available to pass queryString , these are.

In Hyperlink:

    <a href=”~/Default.aspx?id=10&name=Jacob”>QueryString Example</a>

In Response.Redirect method :

 Response.Redirect(“~/Default.aspx?id=10&name=Jacob”);

If we want to get queryString Parameter valuefrom url then we should use Request.QueryString  Object.
Label1.Text=Request.QueryString[“querystring parameter”].ToString();

Lets take an simple example to pass textbox value from one form to another form using QueryString.




<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Default2.aspx?name=" + TextBox1.Text);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.Request.QueryString["name"] != null)
        {
            Label1.Text = "name of the querystring parameter is " + Page.Request.QueryString["name"];
        }
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Enter Name :
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
        <asp:Button ID="Button1" runat="server" Text="QueryString" OnClick="Button1_Click" /><br />
        <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    </div>
    </form>
</body>

</html>
Output
Eample of QueryString in ASP.NET

© Copyright 2013 Computer Programming | All Right Reserved