Skip to main content

Posts

Showing posts from 2013

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

Mathematical Functions to Work with Numerical Values in Sql Server: SQL Programming

In SQL Programming, mathematical functions are used to operate with numeric values. Programmer can easily perform all type of scientific functions as well as simple arithmetic operations using these mathematical functions. Programmer can use mathematical functions to manipulate the numeric values in a result set. You can perform various numeric and arithmetic operations on the numeric values. For example, you can calculate the absolute value of a number or you can calculate the square or square root of a value. The following table lists the mathematical functions provided by SQL Server 2005. Abs , Returns an absolute value Acos, asin and atan , returns the angle in radians whose cosine, sine, or tangent is a floating-point value Cos, sin, cot and tan , returns the cosine, sine, cotangent, or tangent of the angle in radians Degrees , returns the smallest integer greater than or equal to the specified value Exp , returns the exponential value of the specified value Fl

Use Date Functions to Operate with Date Values in Sql Server: SQL Programming

In SQL Programming, programmer can use the date functions of the SQL Server to manipulate date-time values. You can either perform arithmetic operations on date values or parse the date values. Date parsing includes extracting components, such as the day, the month, and the year from a date value. Programmer can also retrieve the system date and use the value in the date manipulation operations. To retrieve the current system date, you can use the getdate function. The following statement displays the current date: SELECT getdate ( ) The following SQL query uses the datediff function to calculate the difference between the current date and the date of birth of employees in AdventureWorks, Inc. The date of birth of employees is stored in the BirthDate column of the Employee table. SELECT datediff (yy, BirthDate, getdate()) AS 'Age' FROM HumanResources.Employee Outputs: The following table lists the date functions provided by SQL Server. dateadd , adds the num

Computer Programming: Add item with value in code file, ASP.NET Example

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="itemwithvalue.aspx.cs" Inherits="itemwithvalue" %> <!DOCTYPE html> <html xmlns=" http://www.w3.org/1999/xhtml "> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>             <asp:RadioButtonList ID="RadioButtonList1" runat="server" Height="65px" Width="235px">         </asp:RadioButtonList>         </div>     </form> </body> </html> Code File using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class itemwithvalue : System.Web.UI.Page {     protected void Page_Load(object sender, EventArgs e)     {         if (!Page.IsPostBack)         {             RadioButto

Computer Programming : TextBox WatermarkExtender control in Ajax with example

Computer Programming : TextBox WatermarkExtender is used to provide a tip to the user that specifies the type of parameter entered within the text box. This extender attaches to a TextBox control and displays a text within the text box when the web page render for the first time. When the user clicks the text box to insert values, the default text gets hidden. Public Properties of TextBox Watermark Extender are TargetControlID : Sets the .ID of the TextBox control to which you want to attach the extender WatermarkText  : Sets the text to display when the value in the text box is empty. watermarkCssClass : Sets the CSS class for the text box when it is empty.   Lets take a simple example <%@ Page Language="C#" AutoEventWireup="true" CodeFile="watermark-example.aspx.cs" Inherits="watermark_example" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %&

JAVA Characteristics and Java Virtual Machine: Introduction to JAVA

After completion of compilation process in java, programmer need to know about what the characteristics of java are and what java virtual machine is. In this article we will cover these two topics which are main part in programming. Java Virtual Machine (JVM)   As you are aware that any source program needs to be either compiled or interpreted before it can be executed. But with Java, a combination of these two is used. Program written in Java are compiled into Java Byte code, which is then interpreted by a special Java Interpreter for a special platform. Actually this Java interpreter is known as the Java Virtual Machine (JVM). The machine language for the java Virtual Machine is called Java byte code. Actually the Java interpreter running on any machine appears and behaves like a “virtual” processor chip, that is why, the name – Java Virtual Machine. The Java Virtual is an abstract machine designed to be implemented on the top of existing Virtual Machine can be implemented

How to Work with Basic Controls in NetBeans: Java Programming

After talking about many elementary concepts and features of GUI in Java, we have reached a point where we can design our first application. But prior to that we shall learn to work with some most common controls. And after that we shall design our very first GUI application . There are many graphical controls that are used in java GUI programming. Here’re the list of common GUI controls used: TextField is a basic field that allows the user to type some textual information. It allows at most one line of input. To input some more lines, programmer have to use TextArea discussed below. Label is another basic control that lets you display uneditable text. It is the basic unit that is used almost in every jFrame in Java GUI Application. Label is used to indicating about to do something like in entry form it indicates about where to enter name, address etc. Button displays common GUI button and performs an action when the users clicks on it or presses Enter key after choosing it.

Use String Functions to Manipulate String Values in Sql Server: SQL Programming

In Sql Programming, programmer can use the string functions to manipulate the string values in the result set. There are list of string functions used in sql server and explained in this article. For example, to display only the first eight characters of the values in a column, you can use the left ( ) string function. String functions are used with the char and varchar data types. The SQL Server provides string functions that can be used as a part of the character expression. These functions are used for various operations on string. Syntax:     SELECT function_name (parameters) Where Function_name is the name of the function parameters are the required parameters for the string function. The following table lists the string functions provided by SQL Server Ascii , returns the ASCII code of the leftmost character, e.g. SELECT ascii (‘ABC’) will return ascii code of 'A'. Char , return the character equivalent of the ASCII code value, e.g. SELECT char (65)    Chari

How to Customize the Result Set using Functions in SQL Server: SQL Programming

SQL server provides some in-built functions to hide the steps and the complexity from other code. Generally in sql programming, functions accepts parameters, perform some actions and return a result. While querying data from SQL Server, programmer can use various in-built functions to customize the result set. Some of the changes includes changing the format of the string or date values or performing calculations on the numeric values in the result set. For example, if you need to display all the text values in uppercase, you can use the upper () string function. Similarly, if you need to calculate the square of the integer values, you can use the power ( ) mathematical function. Depending on the utility, the in-built functions provided by SQL Server are categorized as listed below: String functions Date function Mathematical functions Ranking functions System function. All these functions are for specific use in sql programming like string functions are used to manipulate

Selection Sorting Algorithm in C Language

Selection sort, also called in-place comparison sort, is a sorting algorithm in computer programming. It is well-known algorithm for its simplicity and also performance advantages. The article shows the process with C language code and an example. As the name indicates, first we select the smallest item in the list and exchange it with the first item. Then we select the second smallest in the list and exchange it with the second element and so on. Finally, all the items will be arranged in ascending order. Since, the next least item is selected and exchanged accordingly so that elements are finally sorted, this technique is called selection sort. For example, consider the elements 50, 40, 30, 20, 10 and sort using selection sort. Design : The position of smallest element from i'th position onwards can be obtained using the following code: pos = i; for(j=i+1; j<n; j++) {    If(arr[j] < arr[pos])    pos = j; } After finding the position of the smallest number

How to Delete Multiple Records from DataGridView in Winforms: C#

To remove multiple records from the DataGridView, programmer need to write some line of code, code may be written in a button's click event that is outside of the DataGridView. The article shows about how to select multiple records of DataGridView and the c# code to remove them with a single mouse click. When a programmer have to remove a single record entry from the DataGridView, then a command button can be added as discussed. Removing a single record can be performed by the index of the record. Through the index programmer can easily get all the unique values about the record which helps to perform the action. To remove multiple records, follow the steps written below: Drag-n-Drop DataGridView on the form and set its MultiSelect property to True. Create a list of records (Student Class) and bind this DataGridView with that list. Create a button outside of this DataGridView and generate its click event. Write following C# code in the click event of button to remov

Computer Programming : How to get height and width of an image in ASP.NET

If you want to get uploaded image height and width then you should go for Bitmap class. Suppose I have an image, and I want to get height and width parameter of it. Lets take an simple example You have an image with height and width parameter. You can see in above snap, which is contains 578pixel in wide and 141pixel in height. Now, you want get that these pixel at runtime in ASP.NET. A Bitmap class is used for getting Height and Width of image. Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes. A Bitmap is an object used to work with images defined by pixel data. according to msdn library.     Simple example   <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> &l

How to Create a Project in NetBeans GUI Builder: Java Programming

A NetBeans IDE project is a group of Java source files plus its associated Meta data, including project-specific files. A Java application may consist of one or more projects. All Java development in the IDE takes place with in projects, we first need to create a new project within which to store sources and other project files. To create a new GUI application project: Click File → New Project command. Alternately. You can click the New Project icon in the IDE toolbar or press Ctrl + Shift + N . In the Categories pane, select the Java node and in the projects pane, choose the Java Desktop Application and then Click Next. Enter desired name in the Project Name field and specify the project location. Leave the Use Dedicated Folder for storing Libraries checkbox unselected. (If you are using IDE 6.0, this option ids not available.) Ensure that the Set as Main Project checkbox is selected. Finally click Finish button. Now the NetBeans IDE will create the proje

Connect SqlDataSource Control with Database, Insert, Update and Delete

How to connect SqlDataSource Control with database, also add extra features like insert, update and delete. Here we will take some steps, these are 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 Now generate source code in page file <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-t

Steps to Retrieve Records with SQL Server Management Studio: SQL Programming

As I have discussed in my first SQL article that the database scenario is AdventureWorks, on which we will work on. The AdventureWorks database is stored on the LocalDb (Currently used) database server. The problem we are sorting out is, the details of the sales persons are stored in the SalesPerson table. The management wants to view the details of the top three sales persons who have earned a bonus between $4,000 and $6,000. To retrieve the specified records, programmer need to create a query first and then execute the query to generate the report. To display the top three sales person records from the SalesPerson table, programmer need to use the TOP keyword. In addition, to specify the range of bonus earned, you need to use the BETWEEN range operator. To create the query by using the SQL Server Management Studio, just follow simple steps written below: Select Start>Programs>SQL Server Management Studio to display the Microsoft SQL Server Management Studio Window. Con

How to Add Functionality to NetBeans GUI: Java Programming

Programmer can know, to add graphical components in a frame and how to set their properties . But doing much is not sufficient in java programming, because the graphical controls that you add to frame can’t do anything on their own. In other words, they have the look but not any feel. To add feel i.e. functionality or behaviour to them, you must also know about something called events and listeners. The three major players that add functionality to GUI are: The Event:  An event is an objects that gets generated when user does something such as mouse click, dragging, pressing a key on the keyboard etc. Source of the Event: The component where the event has occurred, is the source of the event. For example, if a user clicks (the Event) on a Submit button then the source of this event is Submit button. Event Listener:  An event listener is attached to a component and contains the methods/functions that will be executed in response to an event. For example, if a user click on a b

How to Retrieve Records without Duplication of Values: SQL Programming

Redundancy is each second programmer’s problem in querying with sql programming. Sql programming provides some in-built keyword that may be used to remove this problem. The article shows syntax and use of this keyword with examples. When there is a requirement to eliminate rows with duplicate values in a column, the DISTINCT keyword is used. The DISTINCT keyword eliminates the duplicate rows from the result set. The syntax of the DISTINCT keyword is: SELECT [ALL|DISTINCT] column_names FROM table_name WHERE search_condition Where column_names: name of fields to be displayed in output. table_name: name of table from which records are to be retrieved. Search_condition: mostly used to filter the output. DISTINCT keyword specifies that only the records containing non-duplicated values in the specified column are displayed. In a query that contains the DISTINCT keyword, you can specify more than one column name. In that case, the DISTINCT keyword is applied to all the c

How to Retrieve Records from Top of Table: SQL Programming

Sql Programming provides a specific keyword that enables programmer to retrieve records from the top of the table. Programmer can use the TOP keyword to retrieve only the first set of rows from the top of a table. This set of records can be either a number of records or a percent of rows that will be returned from a query result. For example, you want to view the product details from the product table, where the product price is more than $50. There might be various records in the table, but you want to see only the top 10 records that satisfy the condition. In such a case, you can use the TOP keyword. The syntax of using the TOP keyword in the SELECT statement is: SELECT [TOP n{PERENT}] column_name [, column_name…] FROM table_name WHERE search_conditions [ORDER BY [column_name [, column_name…] Where n is the number of rows that you want to retrieve. If the PERCENT keyword is used, then ‘n’ percent of the rows are returned. If the SELECT statement including TOP has

How to Retrieve Records to be Displayed in a Sequence: SQL Programming

We have discussed many situations in which programmer retrieve records based on a condition. The purpose of this clause in sql programming, is not to verify the result, but to sort the result set. Using this clause, programmer can sort the records either in ascending or descending order. Programmer can use the ORDER BY clause in the SELECT statement to display the data in a specific order. The order may be ascending and descending, depend on the requirement of query result. The Syntax of the ORDER BY clause: SELECT select_list FROM table_name [ORDER BY order_by_expression [ASC|DESC] [, order_by_expression [ASC|DESC]…] Where Select_list: the list of field names to be displayed. Table_name: name of table from which records are to be retrieved. order_by_expression is the column name on which the sort is to be performed. ASC specifies that the values need to be sorted in ascending order. DESC specifies that the values need to be sorted in descending order. Optionall

How to Use Properties Window to Change Control’s attribute: Java Programming

The controls/objects that a programmer draw on frame/window have some properties associated with them. Each control have its own properties with some common to other controls, which NetBeans enables to change. The Properties Window provides an easy way to set properties for all objects in a frame/window. To open the Properties Window (if it is not open), choose the Properties command from the Window menu. You may also press the shortcut key for it which is: Control + Shift + 7 . A property can be of any type such as integer, string etc. These can be set by either a simple textbox or a dropdown list. The whole thing is properties window consist of the following elements: Title box  Displays the name of the object for which you can set properties. Properties list  The left column under Properties Tab, displays all of the properties for the selected object. You can edit and view settings in the right column. As in previous article we have name a control using inspector win

What are Naming Conventions in NetBeans: Java Programming

Object Naming Conventions, the process of giving a name to the control, basically used to access a control in coding part of programming language. Java NetBeans IDE have its own rules, described in the article, to name a control while programming. A control's name is one of its most important attributes because you literally refer to a control by its name whenever you want it to do something. Names are so important that every time you put a control on your form, NetBeans IDE automatically gives a name to it. If programmer add a jButton, NetBeans IDE names it jButton1; if you add a jTextField, it automatically named jTextField1. However, naming controls like this, may be confusing. While naming controls, you need to take care of these things. Must begin with a letter. Must contain only letters, numbers, and the underscore character (_); punctuation characters and spaces are not allowed. Omit the initial letter "J" in object names and you may add its type at the

How to Perform Actions on Window Controls In NetBeans: Java Programming

There are many controls in the palette tab of NetBeans IDE having specific properties of its own. Those controls can easily be added, resize and delete from the frame, while programming in java. This article have some steps to do these tasks in simple way. To draw a control on Frame/Window in NetBeans Click the desire control’s icon on the Palette. (Say, for example, we want to draw a label. For this we shall first click at its icon on the palette.) Now drag it to desired location in your Frame/Window. Se the control that you selected, now appear on your frame/window. When you can add controls to your frame, you might find strange behavior of IDE regarding component positioning and sizing. (This is because of Free Design layout manager.) In order to have full control on component's positioning and sizing, you need to know about Layout Managers. The layout of components on a frame (or panel) is controlled by a layout manager, which determines the final placement of ea

How to Retrieve Records containing Null Values: SQL Programming

In Sql programming, when programmer want to retrieve records that have null values in their columns. To get such type of records, sql queries must have NULL operator in the where clause. A NULL value in a column implies that the data value for the column is not available. You might be required to find records that contain null values or records that do not contain NULL values in a particular column. In such a case, you can use the unknown_value_operator in your sql queries. The syntax of using the unknown_value_operator in the SELECT query is: SELECT column_list FROM table_name WHERE column_name unknown_value_operator Where Column_list: list of fields to be shown in output. Table_name: from the records are to be retrieved. unknown_value_operator is either the keyword IS NULL or IS NOT NULL. The following SQL query retrieves only those rows from the EmployeeDepartmentHistory table for which value in the EndDate column is NULL. SELECT BusinessEntityID, EndDate FROM

How to Retrieve Records that Matches a Pattern: SQL Programming

When retrieving data in sql programming, you can view selected rows that match a specific pattern. For example, to create a report that displays all the product names of Adventure Works beginning with the letter P. This task can be done through the LIKE keyword. The LIKE keyword is used to search a string by using wildcards. Wildcards are special characters, such as * and %. These characters are used to match patterns and some of them are described with example, mostly used by sql server: %     Represents any string of zero or more character(s) _     Represents a single character []     Represents any single character within the special range [^]     Represents any single character not within the specified range The LIKE keyword matches the given character string with the specified pattern. The pattern can include combination of wildcard characters and regular characters. While performing a pattern match, regular characters must match the characters specified in the chara