Skip to main content

Posts

Showing posts from November, 2015

Featured Post

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

How to determine version of MVC application

In this article, I will show you how to check  MVC version of application. There are two methods, through which we can get the version of MVC. In the first method we use property of System.Web.MVC namespace. But, How to check, check the mentioned snap shots. 1. Expand References folder  2. Right click on System.Web.MVC namespace also select property , check the mentioned snap. II-Method using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace WebApplication9.Controllers {     public class HomeController : Controller     {         // GET: Home         public string Index()         {             return typeof(Controller).Assembly.GetName().Version.ToString();         } } }

Drop Shadow example in WPF

In this article, I will show you, How to create Shadow of controls. Through this, we can show 3d view of control. First of all, I will apply this style on manually created designs like Ellipse, Rectangle etc. After that I will apply same things on controls. So, add a new window in the project. Add this code in between the <grid> ...</grid> section of xaml file.  <Rectangle Height="150" Width="150" Stroke="Black" StrokeThickness="2">             <Rectangle.BitmapEffect>                 <DropShadowBitmapEffect Color="Black" Direction="-50" ShadowDepth="40" Softness=".8"/>                             </Rectangle.BitmapEffect>             <Rectangle.Fill>                 <ImageBrush ImageSource="apple.png"/>                             </Rectangle.Fill>         </Rectangle>       BitmapEffect creates the shadow

How to use Hyperlink in MVC

In my previous article i have already learned about hyperlink and their uses, we have already use hyperlink in different application like asp.net. Previous article coves all such things like hyperlink properties and methods. Today i am talking about hyperlink in MVC, and how to use it.    The given snap shows that how MVC work. According to the sanp view show the all tags of html. In MVC application, we use ActionLink extension of HtmlHelper. I have show the syntax and example of Hyperlink. Syntax: @Html.ActionLink(String LinkText, String actionName) Example @Html.ActionLink("Hello World","Hello") Action Method in Controller class public string Hello() { return "Hello World!"; } OK Done this is complete. Now, Today we have also learn how to bind hyperlink from database table in MVC. First to prepare the class for employee entity in model folder also map this with database table(mentioned in previous article), Now your code lo

Getting started with MVC 4

Introduction Model-View-Controller(MVC) has been an important architectural pattern in computer science for many years. Originally named "Tbing-Model-View_Editor in 1979. It was later simplified to Model-View-Controller. It is a powerful and elegant means of separating concerns within an application (for example, separating data access logic from display logic) and applies itself extremely well to web applications. The MVC separates the user interface of an application into three main aspects:   The Model  : A set of classes that describes the data you're working with as well as the business rules for how the data can be changed and manipulated. The View : Defines how the application's user interface(UI) will be displayed. The Controller : A set of classes that handles communication from the user, overall application flow, and application specific logic. Lets take an simple example : follow some steps for creating first MVC application Step-1 : Goto file-&

Getting Started to Build Web Applications: Introduction to MVC

MVC (Model View Controller), most usable framework for latest web programmer, enables programmer to separates their work in these three names. It is a lightweight and standard design pattern which is familiar to many web developers. According to the name of this framework, the application divides itself in three things i.e. one contains your logic, one contains your pages (may be razor or aspx pages) and the last one will contain some classes which are used to control the pages redirecting per user clicks. The following diagram shown about the layers of this framework which includes Business layer, display layer and input control. Model , used to represent the core of web application. To interact with database tables there are some classes have to be written. Those classes must be placed in the model folder to follow the MVC framework. It means all the logic, works for the application, falls in this category. View , used to decide about the display of data on the pages.

Getting started with MVC Application

Getting started -Introduction MVC is a framework used for building web application using latest and somewhat different approach. According to this architecture, whole application divides in to three part i.e. Model, View and Controller which is also the pronunciation stands for MVC. Model: keeps the application core. It includes some classes written to interact with database. View: how is to be displayed on the page? falls into this category. Controller: what is to be transfer on the views? falls into this category. More about MVC can be easily read through here , but we will start some practical work here. I suppose every DotNet programmer knows about Visual Studio. Let’s start with creating a new MVC application using below steps. Step 1. Create new project and select ASP.NET MVC 4 Web Application under the Web categories. Step 2. Change the directory where solution will exist, it takes default if not changed and click on OK button. Step 3. It will asks about the typ

How to read data from excel file in ASP.NET, Example

This article will cover, How to read data from Excel spreadsheet using ASP.NET. First we need to connect Microsoft Excel workbook using the OLEDB.NET data provider. Add excel file path to connectionString, after doing this the connectionstring will be look like string connString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("first.xls") + ";" + "Extended Properties=Excel 4.0;"; Here, you can connect .xls file using Microsoft.Jet.OLEDB.4.0 provider also display data into gridview. In Data Source, you can take .xls file path. You can follow some steps for reading data from excel file.  Step 1: Open Visual Studio > File > New >Website > Under Templates, click ASP.NET WebSite and choose Visual C# as the language. Select a system location and click Ok. Step 2: We will create excel sheet and add them to the website folder. Excel sheet will be created in Office 2003(first.xls). Step 3:

WPF Window attribute | Properties examples

Introduction In this article, we will learn many more attributes or you can say properties of window tag in WPF. First of, I will take Width and Height properties of Window Tag. Width defines Horizontal size of window and Height vertically. Both takes numbers. If you do some changes in these attribute then your window will resize. Now, come to Next attribute that is Title , Define the label of title bar, which is the Top most bar of your window. Title is aligned in center bydefault.  Icon : If you want to put image in left corner which is realted to your project like suppose your project window is related to login, now you can put login image into your title bar in left corner. ResizeMode : Change the window size at run time, if you want. Minimize and Maximize button appear by using this arrtibute. Also you can hide both buttons, if you assign "NoResize" value in it. By using this value, hide minimize and maximize button as well as resize arrow.  ShowI

Example domainUpDown control in windows form c#

Introduction In this article, we will see, How to use domainUpDown control in windows form c#. This control is used to choose single item at time, In this we have multiple options. If you see this control then you notice that this control is similar to Numeric UpDown control. But NumericUpDown control display numbers only. domainUpDown control display string like display month's name and many more things. In this article we will see many more interesting things which are related to domainUpDownControl. How to use doaminUpDown Control First of all add domainUpDown control from ToolBox Copy this code paste into your code file     private void Form2_Load(object sender, EventArgs e)         {             DomainUpDown.DomainUpDownItemCollection collection = this.domainUpDown1.Items;             collection.Add("Jan");             collection.Add("Feb");             collection.Add("Mar");             collection.Add("Apr"

How to get cell value from dataGridView in windows form c#

In this article, I will teach you, How to get cell value from dataGridView in windows form c#. First of all bind the dataGridView with any Data Source then you can access cell value from it. I bind it with many data source, check this link . In previous article, I get the cell value from selected row of  dataGrid but on this time, we set the default row. In this article, I will give an example of cell click event. private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)         {                   decimal accno = Convert.ToDecimal(dataGridView1.Rows[e.RowIndex].Cells[0].Value);             MessageBox.Show(accno.ToString()); } Here, Cells[0] return the first column's cell value from dataGridView.

LOAD IMAGE WITH IMAGE DATATYPE INTO TABLE IN ASP.NET WEBFORM

In this article, I will teach you, How to load image into database table with image type in ASP.NET. In previous article i already explained how to save image with their path.So, If you want to do this task then first of all design a table with image datatype. Database table Source code  <form id="form1" runat="server">     <div>           <asp:FileUpload ID="FileUpload1" runat="server" />       </div>         <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />     </form> Code behind page using System.Drawing; using System.IO; protected void Button1_Click(object sender, EventArgs e)     {         BankingSystemEntities1 BS = new BankingSystemEntities1();         Bitmap bitmap;         if (FileUpload1.HasFile)         {             FileUpload1.SaveAs(Server.MapPath("~/image/" + FileUpload1.FileName));  

Get data From Database table using EDMX in ASP.NET

In this article, I will show you, how to get data from Database table using EDMX file. Actually EDMX reduces lots of codes, you can see this article which contains lots of codes. EDMX file provides model as well as context class. By using public property of context class, we can communicate with the table.  Before copy this code, first to add EDMX file in solution. Source code <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div> </form> Code Behind   private void loadgrid() { //throw new NotImplementedException(); dbEntities dbe = new dbEntities(); var item = dbe.usertables.ToList(); GridView1.DataSource = item; GridView1.DataBind(); }

Insert data into Database table WPF

In this article, I will show you how to insert data into Database table using EDMX file. So, before copy this code first to add EDMX file in the project with full configuration. In the source code, we have two text block, two text box and one button control. Description I explained, example of login form in WPF , WPF listview with item template binding , Start learning with WPF , Source code (XAML) <Window x:Class="WpfApplication7.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> <TextBlock HorizontalAlignment="Left" Margin="75,68,0,0" TextWrapping="Wrap" Text="Username" VerticalAlignment="Top"/> <TextBlock HorizontalAlignment="Left" Margin="75,124,0,0" Te

Get last record from Database using LINQ in WPF

Today, I faced a problem which is related to banking application like account number. When I load the application to create new account for new customer then account number automatically increased by one from previously stored account. So, I want to pick last field value of Database table. Let's see the example: <Grid> <Button Content="Button" HorizontalAlignment="Left" Margin="70,79,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/> </Grid> Code behind code private void Button_Click(object sender, RoutedEventArgs e) { DatabaseEntities dbe = new DatabaseEntities(); var getlastrec = dbe.users.ToArray().LastOrDefault(); MessageBox.Show(getlastrec.Id.ToString()); } Here DatabaseEntities is the context class. In this context class, we have public properties that is users. Through this we can get all records from user