Skip to main content

Posts

Showing posts from January, 2014

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 });             }            

DropdownList SelectedIndexChanged page reload but value not change

Introduction  If you want to bind one DropdownList from another DropdownList. But you notice that your first DropdownList take same result, After PostBack your page will refreshed, again Page_Load function will be run. The reason behind Because your first Dropdownlist bind on Page_Load Event  with both postback and without postback mode . Solution of the problem is   Bind first DropDownList on Page_Load event with withoutPostBack mode. Lets take an simple example to demonstrate it <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat=&quo

How to Querying Data using Joins in Sql Programming: Part 4

Equi Join In SQL programming, an Equi join is the same as an inner join and joins tables with the help of a foreign key. However, an equi join is used to display all the columns from both the tables. The common column from all the joining tables is displayed. Consider an example where you apply an equi join between the EmployeeDepartmentHistory, Employee, and Department tables by using a common column, BusinessEntityID. To perform this task, you can use the following query: SELECT * FROM HumanResources.EmployeeDepartmentHistory d JOIN HumanResources.Employee e ON d.BusinessEntityID = e.BusinessEntityID JOIN HumanResources.Department p ON p.DepartmentID = d.DepartmentID The output of this query displays the EmployeeID column from all the tables, as shown in the following figure. Self Join In a self-join, a table is joined with itself. As a result, one row in a table correlates with other rows in the same table. In a self-join, a table name is used twice in the query. Th

How to Querying Data using Joins in Sql Programming: Part 3

A cross join, also known as Cartesian Product in SQL programming, between two tables joins each row from one table with each row of the other table. The number of rows in the result set is the number of rows in the first table multiplied by the number of rows in the second table. This implies that if Table A has 10 rows and Table B has 5 rows, then all 10 rows of Table A are joined with all 5 rows of Table B. therefore, the result set will contain 50 rows. Consider following query in which all the BusinessEntityID is retrieved from SalesPerson table and SalesTerritory with their cross join. The where condition will filter the result according to the territoryID, and at the last the result will sort by the resulting BusinessEntityID. SELECT p.BusinessEntityID, t.Name AS Territory FROM Sales.SalesPerson p CROSS JOIN Sales.SalesTerritory t WHERE p.TerritoryID = t.TerritoryID ORDER BY p.BusinessEntityID The preceding query combines the records of both the tables to display the

Item selection required for ListBox in ASP.NET

If you want to do it in asp.net that your website visitor select any one option in given ListBox item. Use Required Field Validator for this type of problem, also set initial value. If your initial value is match with your selected item, error message generated on client machine. lets do it in asp.net with sort code example Selection is required  <%@ 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"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>         <strong>Selection Required<br />         </strong>     </div>         <asp:ListBox ID="

Bind DetailsView with insert, edit and delete in ASP.NET

You can easily bind your DetailsView data control in asp.net using SqlDataSource, SqlDataSource provides connectivity between front end to back-end with all insert, edit and delete features. This example covers that how to bind your DetailsView with database. These are following steps Step-1 : Create a SQL Table with some fields like sno int (primaryKey, Isidentity=true) name nvarchar(50) address nvarchar(250) Step-2 : Add SqlDataSource Control to Design window from toolbox Step-3 : Select 'Configure Data Source' link using show Smart tag. Step-4 : Select Database or ConnectionString from Dropdown menu. Step-5 : Select Table-name from Dropdown menu also select Advanced tab. Step-6 : Select Insert, Update and delete checkbox option. Step-7 : Click to Test Query and  Finish button. Step-8 : Add DetailsView Control to the page, check all insert, update, and delete features using show smart teg. Now generate source code in page file <

Accept only numbers by the TextBox in ASP.NET

If you want to do it in asp.net that your TextBox accept only number when user input in it. Use CompareField Validator for this type of problem, Normally we use CompareField Validator for password recheck. Today we use it for another purpose, now, take an example. Accept Only integer type number by TextBox Step-1 : Add webform into the project. Step-2 : Take one TextBox and Button control onto the webform. Step-3 : Also take one Required field and one compare field validator onto the web form. Step-4 : Set Property of required field validator, these are ControlToValidate="TextBox1" Display="Dynamic" ForeColor="#CC0000" Text= "Required" Step-5 : Set Property of CompareField Validator, these are ControlToValidate="TextBox1"  Display="Dynamic"   ForeColor="#CC0000"   Operator="DataTypeCheck"    Type="Integer"    Text= "Enter Only numbers" Complete code <%

Examples of some common Algorithms of DataStructure in C programming

1.Algorithm to find the average of  a subject marks of ‘N’ number of students.              AVG_OF_MARKS (LIST, N)             [LIST is an array containing marks, N is the size of array]             SUM 0             Repeat For I=1,2,3, …N                SUM  SUM  + LIST[i]             [End of For I]             AVG SUM/N             Write: ‘The average is’,AVG             Exit. 2.Algorithm to find average of SALARY in an array of EMP struct containing information EMPNO, EMPNAME, and SALARY.         AVG_SALARY (LIST, SIZE)         [LIST is an array of EMP, SIZE is size of array]         SUM 0         Repeat For I=1,2,3, …SIZE           SUM SUM  + LIST[I].SALARY        [End of For I]        AVG  SUM / SIZE        Write: ‘The average Salary is’,AVG        Exit. An algorithm, that performs sub task, may be called in another algorithm. It is better practice to divide the given problem into sub problems and write the individual algorithms to solve s

Insert element in Array in PHP Programming

Insert element in PHP array:-                                                                               If we wish to insert a new item or element in PHP array then we have three choices first is insert the element  from fist position , second is insert the element  at last position and third is insert the element at any desire position in an array. Here following code is showing that how to implement above three operations. • Insert the element from starting of array: - We can do this we use PHP array_unshift() function. Syntax of this function is follows:-               Int  array_unshift(array array, mixed variable [, mixed variable...]) So we can use any element to the array which is passed in this function  this can be understand with the help of following code. : $names = array("jack”,“jon"); array_unshift($states,"weilems","reacher"); after this statement the array name  becomes $names = array("jon","jacob",&q

How to Querying Data using Joins in Sql Programming: Part 2

In comparison to an inner join , an outer join displays the result set containing all the rows from one table and the matching rows from another table. For example, if you create an outer join on Table A and Table B, it will show you all the records of Table A and only those records from Table B for which the condition on the common column holds true. An outer join displays NULL for the columns of the related table where it does not find matching records. The syntax of applying an outer join is: SELECT column_name, column_name [, column_name] FROM table1_name [LEFT | RIGHT| FULL] OUTER JOIN table2_name ON table_name.ref_column_name An outer join is of three types: Left Outer Join A left outer join returns all rows from the table specified on the left side of the LEFT OUTER JOIN keyword and the matching rows from the table specified on the right side. The rows in the table specified on the left side for which matching rows are not found in the table specified on the right si

Reference Data Types in Java Programming

Any type of storage that stores an address or we can say reference of object in memory, called Reference data type. Java like other language have also some reference data types discussed in the article. Broadly a reference in Java is a data element whose value is an address of a memory location. Arrays (a group of similar data items), classes (a blue print of some entity e.g. a student) and interfaces are reference type. The value of reference type variable, in contrast to that of primitive type, is a reference to (an address of) the value or set of values represented by variables. A reference is called a pointer, or memory address in other language. The java programming language does not support the explicit use of addresses like other languages do. You use variable’s name instead. An importance reference type that you use in Java is String type. The String type lets you create variables that can hold textual data e.g. “Mohan”, TZ194”, “194ZB”, “234” etc. Anything that you e

Create PHP Array in PHP Programming

Create PHP array :-                                We have following methods to create an array in PHP. • To assign index and key manually to the variable: - In this method we have to provide a specific index value as well as key value to the variable. This can be understood with the help of example. Let we want an array named “record” to store different information of students such as name, age , id, and marks. Here the variable “record” act as an array and store all these information in following way. In this example we use an array variable $record to store different elements. Now we have following properties this PHP array. • Index range for this array is 0-3.where minimum index is 0 and maximum index is 3; • Maximum item that this array can store is 4. • A PHP array can store different type of elements like integer or string or double etc. because php takes the type of data automatically corresponding to that. • In above program we use the function print_r

How to use TextChanged event of TextBox with AutoPostBack in ASP.NET

ASP.NET application works on AutoPostBack model, i mean, if we want to run code behind event like TextChanged event then we must set AutoPostBack property is true.   <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>         Search Item<asp:TextBox ID="TextBox1" runat="server"              AutoPostBack="True" Width="174px" ontextchanged="TextBox1_TextChanged"></asp:TextBox>         <br />         <br />     </div>     <

Algorithmic Notation in DataStructure, C Programming

Algorithm is a sequential, finite non-complex step-by-step solution, written in English like statements, to solve a problem. Here we can consider some points about the algorithmic notation, which are helpful in writing algorithms to understand the basic data structure operations clearly. Algorithm writing is first step in implementing the data structure. 1.Name of the algorithm and parameters: Name of the algorithm may be written in capital letters and the name is chosen according to the problem or operation specification. The name may depict the work done by algorithm is called can be given as parameter names immediately followed by name of the algorithm in a pair of parenthesis.            e.g.     TRAVERSELIST (LIST, SIZE)                        LINEARSEARCH (LIST, SIZE, ITEM) The name of algorithm serves the purpose of start for algorithm and it is the heading of algorithm, and further statements of algorithm are written after the heading. s using any of the programming l

Character and Boolean Data Types used in Java Programming

Java programming have some more data types for storage of single character and even true/false values. These data types are called Character and Boolean in programming language. Character Type The character data type (char) data type of Java is used to store characters. A character in Java can represent all ASCII (American standard Code for Information Interchange) as well as Unicode characters. The Unicode character representation code can represent nearly all languages of world such as Hindi, English, German, French, Chinese, and Japanese etc. And because of Unicode character, size of char data type of Java is 16 bits i.e., 2 bytes in contrast to 1 byte characters of other programming languages that support ASCII. Type: Char (Single Character) Size:   16bits (2 bytes) Range: 0 to 65536 Boolean Type Another type of the primitive data type is Boolean. A Boolean value can have one of two values: true or false. So this data type is used to store such type of values.

Draw graphics in ASP.NET

You can draw graphics on browser window using Graphics class. This class exists in System.Drawing namespace. It provide different types of graphics methods, such as DrawArc, DrawImage, DrawIcon, DrawLine and many more. Graphics class hold pen instance for creating graphics onto the screen. Algorithm Behind the drawing Step-1 : First define the graphics area on browser window using Bitmap class. Step-2 : Create instance of Graphics class and initialize with Bitmap class instance. Step-3 : Create Pen class object with specified color and width. Step-4 : Create starting point and ending point using Point class. Step-5 : Draw graphics and save into Bitmap instance. Lets take an simple example of drawing Line , Rectangle in asp.net  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/x

Operations on Data Structures, C programming

Basically there are six operations one can do on the data structures. They are Traversing , Searching, Sorting , Insertion , Deletion and Merging . 1.   Traversing: Basically to process a data structure if every element of data structure is visited once and only once, such type of operation is called as TRAVERSING. For example to display all the elements of an array, every element is visited once and only once, so it is called as traversing operation.             Suppose we have an array of 20 students’ average makes, and if we need to calculate the average of group, we visit (read) each individual average and accumulate (sum) them. Then we will find the array are visited once and only once. Then it is traversing of an array . 2.   Insertion : When an element of the same type is added to an existing data structure, the operation we are doing is called as Insertion operation. The element can be added anywhere in the data structure in the data structure. When the element is add