Skip to main content

Posts

Showing posts with the label Programming

ASP.NET MVC 5 (Part 3)

In this tutorial, we will discuss the " View" and "Model" part from the MVC framework.  As we already knew, a model class does not depend on the controller and view classes. Model class represents the data of the application.  Public properties of model classes hold the data. All model classes reside in the Model folder. Let's see how to add a model class in MVC Project.  Model Let's add a model class in the project MVCProject which we have created in my previous article  ASP.NET MVC 5 (Part 1) .Right-click on the  Models  Folder and click  Add->Class. In the  Add New Item  dialogue, Enter the class name  "Student"  and click the Add button.    Add properties which will hold the student information. So, this is our model class. Let's discuss "View" part of the  MVC . View A view is a user interface. view display data from the m...

Linked List Data Structure

A linked list is a linear data structure just like arrays but its elements do not store in the contagious location. Elements in a linked list are connected through pointers as shown in the below image. Link list consists of nodes. Each node contains a data field and a pointer reference to the next node in the list. Important Points about the linked list A linked list can be used to store linear data of diffent type. Dynamic size. Ease of insertion and deletion of an element. Random access of an element is not allowed. if we want to search an element we have to go sequentially starting from the first node.  Extra memory space would be required for the pointer with each element of a linked list. A linked list is represented by a pointer to the first node o the list. The first node called head.if the linked list is empty then the head is NULL. Let's start implementation of a simple linked list in C# I have created a project of the consol...

A Beginner's Tutorial for Understanding Windows Communication Foundation (WCF)

In this article, we will create a WCF service. Firstly, we will discuss some basics understanding of WCF services. Basics of WCF services WCF Services can be used to communicate with different type of applications using different protocols. if we want to use the WCF services we will have the basic understanding of its main components which is called ABC. Let's discuss these main components of WCF services one by one. Address A WCF provides a URI which can be used to locate the WCF services. This URI called the address of the WCF service. Binding Once we are able to locate the WCF service , The  next point is how to communicate with WCF service like which protocol will be used to communicate. the binding which defines how the WCF service handle this communication, it also defines other communication parameters like message encoding Contract The contract defines  what public data and inter...

How to send Email through ASP.NET in C#

Sending Email through ASP.NET is very easy.the .NET framework comes with a namespace which is uses for handling the Email.The namespace is:                                                            System.Net.Mail namespace Here i am using the two classes of the above mentioned namespace.The first class is MailMessage  class which is used for actual email and second is SmtpClient class which is for sending Email. Write the following code into the page load event: try { MailMessage mailMessage = new MailMessage(); mailMessage.To.Add( " test@domain.com " ); mailMessage.From = new MailAddress( " test2 @ domain.com " ); mailMessage.Subject = " Test Email " ; mailMessage.Body = " This is an ASP.NET test E-mail! " ; SmtpClient smtpClient = new SmtpClient( " smtp .te...

How to upload a file on the server through upload control in asp.net

With ASP.NET upload a file on the server is very easy.With FileUpload control we can easily upload a file on the server.Following markup is required.   < form id ="form1" runat ="server" > < asp:FileUpload id ="FileUploadControl" runat ="server" /> < asp:Button runat ="server" id ="btnupload" text ="Upload" onclick =" btnupload _Click" /> < asp:Label runat ="server" id ="lblstatus" /> </ form > Here is the CodeBehind code required to handle upload a file on the server. protected void btnupload _Click( object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath( " ~/ " ) + filename); lblstatus .Text = " Upload status: Fi...

How to use ASP.NET AJAX UpdateProgress Control

Some time we have a method which takes a bit more time to execution.Due to this time consumption user get impatient One of  Ajax control solved this problem which is ASP.NET AJAX Update Progress Control. ASP.NET AJAX Update Progress Control provides status information about page updates. Here I am going to explain how to use ASP.NET AJAX Updated Progress Control in a web page. Firstly we need a animated GIF.I am using the following image.  In case of Visual studio 2005 install AjaxControlToolkit and in case of Visual studio 2010 add AjaxControlToolkit.dll in the project. Firstly we have to add scriptmanger inside the form tag.   <asp:ScriptManager ID="ScriptManager1" runat="server" />  And Use updatePanel because we need partial update of page. And drag updateProgress from toolbox to the page.                                      After that page will b...

ASP.NET AJAX PasswordStrength Extender

  AJAX Password Strength Extender shows the strength of user chosen passwords.the strength can be show in a  text form, a bar indicator or combination of both.Now i am going to show you how to add ajax password extender control to a asp.net page, In case of Visual studio 2005 install AjaxControlToolkit and in case of Visual studio 2010 add AjaxControlToolkit.dll in the project. I have added a text box and a label control in the page and page will be look like this:                                               After that Add password strength code in the aspx file of the web page. <body>     <form id="form1" runat="server">         <asp:ScriptManager ID="ScriptManager1" runat="ser...

C# Console Application

A Console Application Screen is look like this:     To Create Console Application open Visual studio and click File from the menu bar at the top.From the file menu select New Project. When you click on New Project Following window will be appear.                                                                                                  In Case of Visual Studio 2010 window will be look like this: When you click OK , a new Console Application Project will be created.Some Code should be displayed.    Above is the Program.cs File in the Solution Explorer.Here You can write code according t...

How to write events in C#

We're going to display a simple message box when the button is clicked.So we need a coding window. To see the code for the button double click the button you added to the form. the coding window will open, and your cursor will be inside of the button code. It will look like this:   We want to display a message box, with some text on it. This is quite easy to do in C#. Position your cursor between the two curly brackets. Then type a capital letter "M". You'll see the IntelliSense list appear:            After type 'ess' You'll see the IntelliSense list appear:                                                                          When you have MessageBox selected, hit...

How to add Controls to a Blank C# Form

If you want to add a control to a form, you can use the Toolbox on the left of Visual Studio. Move your mouse over to the Toolbox, and click the plus symbol next to Common Controls. You should see the following list of things that you can add to your form: Toolbox Click the Button item under the Common Controls heading. This will select it. Now click once anywhere on your form. A button will be drawn for you, and your Form will look like this: Form                                           Similarly you can drag and drop different controls on the Form According to your requirements. The text on the button, which defaults to "button1", can be changed from properties windows.  A property of a control is things like its Height, its Width, its Name, its Text, and a whole lot more ...