Monday, 14 May 2018

What is ASP.NET? Components of ASP.NET

ASP.Net Definition-It is used for creating web-based applications.ASP.Net is a web development platform provided by Microsoft. ASP.NET is not just the next version of ASP; it is the next era of web development.  ASP.Net was first released in the year 2002. It is allows you to use a full featured programming language such as C# (pronounced C#) or VB.NET to build web applications easily.

ASP.NET Components:-

                ASP.Net is a framework which is used to develop a Web-based application.
                       CLR- Common Language Runtime

Language: - (i) VB.Net
                     (ii) C#
                     (iii)F#  
 
Architecture of the .net Framework Details of Explanation:-

Language: - Language is defined as VB .net and C# these can be used to development web application.

Library: Library used for web applications in .net is the Web library. The web library has all the necessary components used to develop.Net web-based applications.

Common Language Runtime: - The Common Language Infrastructure is a platform. .Net programs are executed on this platform. The CLR is used for performing key activities and included Exception handling and GC (Garbage collection).

Tuesday, 8 May 2018

Defination Of Validation and Type of Validation


Defination Of Validation:-

Validation is most part of any web application. It is validate the user input data. It is used to
implement page level validity of data entered in the server controls.

There are two type of validation here:-
A-Client Side Validation
B-Server Side Validation
A-Client Side Validation:-It is good client side validation. Client side validation is dependent on the browser  and also scripting language.
B-Server Side Validation:- server validation will work always whether client validation is executed or not.

There are six types of validation controls in ASP.NET
  1. Required Field Validation Control
  2. Compare Validator Control
  3. Range Validator Control
  4. Regular Expression Validator Control
  5. Custom Validator Control
  6. Validation Summary
Explain Members:-
Members
Describe to members
A.    EnableClientScript
A.    Indicates whether client side validation will take.
B.    ControlToValidate
B.    Indicates the input control to validate.
C.    Enabled     
C.    Enables or disables the validator.
D.    Display      
D.Indicates how the error message is shown.
E.    Text           
E. Error text to be shown if validation fails.
F.    ErrorMessage
F. Indicates error string.
G.    SetFocusOnError   
G. It indicates whether in case of an invalid control, the focus should switch to the related input control.
H.    IsValid
H. Indicates whether the value of the control is valid.
I.      Validate()
I. This method revalidates the control and updates the IsValid property.
J.     ValidationGroup
J. The logical group of multiple validators, where this control belongs.

1-Define Required Field Validation Control :-
          It is very easy and useful validation .You can use it to make sure that the user has entered something in a Textbox control.
For Example:-
<form id="form1" runat="server">
    Last Name:<br />
    <asp:TextBox runat="server" id="txtLastName" />
    <asp:RequiredFieldValidator runat="server" id="reqName" controltovalidate="txtName" errormessage="Please enter your Last name!" />
    <br /><br />
    <asp:Button runat="server" id="btnsave" text="Submit" />
</form>

Last Name

Please Enter Last Name
2-Define Compare Validator Control:-
              Compare Validator Control is used to compares the value of one input control to the value of another input control or to a fixed value and used between to input value in textbox.


For Example:-
Password :<br />
<asp:TextBox runat="server" id="txtPass" /><br /><br />
Retype Password:<br />
<asp:TextBox runat="server" id="txtRtyPass" /><br />
<asp:CompareValidator runat="server" id="PAAS_Number" controltovalidate=" txtPass " controltocompare=" txtRtyPass " errormessage="The Password should be Retype Password is Same!" /><br />


Password
Reset*123
Retype Password
Reset*1234
The Password should be Retype Password is Same

3-Define RangeValidator :-

The Range Validator Server Control which checks to see if a control value is within a valid range. The attributes that are necessary to this control are: big value(It specifies the minimum value of the rang), small(It specifies the maximum value of the range.) value, and Type(Currency, Date, Double, Integer, and String).

Date:<br />
<asp:TextBox runat="server" id="txtDate" />
<asp:RangeValidator runat="server" id="Daterang" controltovalidate="txtDate" type="Date" minimumvalue="01-01-2018" maximumvalue="31-12-2018" errormessage="Please enter a valid date within 2018!" />
<br /><br />

     For Example:

Date
31-02-2018
Please Enter a valid date within 2018

 

                       

4-Define Regular Expression Validator:-

The Regular Expression Validator permit to validating the input text by matching against a pattern of a regular expression. The regular expression is set in the Validation Expression property and used to identify simple and complex characters sequence that would otherwise require writing code to perform.
For Exmaple of Email Id:-
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Style="top334px;
        
left400pxpositionabsoluteheight20pxwidth150px" 
        
ErrorMessage="RegularExpressionValidator" ControlToValidate="txt5" 
        
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
Enter Email_ID
princes.com
Please Enter a valid Email_id
 
  1.           Custom Validator Control

5-Define Custom Validator Control:-

The Custom Validator control permitted to writing application specific custom validation routines for both the client side and the server side validation. The control permit to validate both client side and server side, where the server side approach is probably the most powerful. Of course, doing server side validation requires a post back to validate, but in most cases, it’s not really issue. 
For Example:
Custom text:<br />
<asp:TextBox runat="server" id="customtxt" />
<asp:CustomValidator runat="server" id="cusstomcus" controltovalidate="txtCustom" onservervalidate="cusCustom_ServerValidate" errormessage="The text must be exactly 7 characters long!" />
<br /><br />

6-Define Validation Summary Control:-

    
It Defined validation summary control does not perform any validation but shows a summary of all errors in the page. The summary displays the values of the ErrorMessage property of all validation controls that failed validation.
<asp:ValidationSummary ID="valsum1" runat="server"
   DisplayMode = "BulletList" ShowSummary = "true" HeaderText="Errors:" />




Tuesday, 27 October 2015

Sql Query

A

Here we will explain some important sql query that is used in your daily routine in find record in database.


**get  Department ,no of employees in a department ,total salary with respect to a department from employee table order by total salary-

Here show sql table data of employee:---


Table Name---------Employee
Employee_id
First_name
Last_name
Salary
Joining_date
Department
1
Pankaj
Kumar
1000000
2013-01-01 00:00:00.000
Sr. Programmer
2
Ranchiki
Singh
800000
2013-01-01 00:00:00.000
HR Manager
3
Gaurav
Singh
700000
2013-02-01 00:00:00.000
CA
4
Vijay
Singh
600000
2013-02-01 00:00:00.000
SALES MANAGER

Now write a query exactly for output result...

select department,COUNT(First_name),SUM(salary) totalsalary from Employee group by Department order by totalsalary desc


Here is output result to get  DEPARTMENT ,NO OF EMPLOYEES IN A DEPARTMENT ,TOTAL SALARY WITH RESPECT TO A DEPARTMENT FROM EMPLOYEE TABLE ORDER BY TOTAL SALARY.....

department
(No column name)
totalsalary
Sr. Programmer
1
1000000
HR Manager
1
800000
CA
1
700000
SALES MANAGER
1
600000


B


**get  Department wise average salary from employee table order by salary ascending-

Table Name---------Employee
Employee_id
First_name
Last_name
Salary
Joining_date
Department
1
Pankaj
Kumar
1000000
2013-01-01 00:00:00.000
Sr. Programmer
2
Ranchiki
Singh
800000
2013-01-01 00:00:00.000
HR Manager
3
Gaurav
Singh
700000
2013-02-01 00:00:00.000
CA
4
Vijay
Singh
600000
2013-02-01 00:00:00.000
SALES MANAGER

Note:-The GROUP BY clause is used with the SQL SELECT statement

select department,AVG(salary) avgsalary from Employee group by department order by avgsalary asc


Output :Here is output department details and avgsalary detail of employee.

department
avgsalary
SALES MANAGER
600000
CA
700000
HR Manager
800000
Sr. Programmer
1000000


C


**get  Department wise Maximum salary from employee table order by salary ascending-

Table Name---------Employee
Employee_id
First_name
Last_name
Salary
Joining_date
Department
1
Pankaj
Kumar
1000000
2013-01-01 00:00:00.000
Sr. Programmer
2
Ranchiki
Singh
800000
2013-01-01 00:00:00.000
HR Manager
3
Gaurav
Singh
700000
2013-02-01 00:00:00.000
CA
4
Vijay
Singh
600000
2013-02-01 00:00:00.000
SALES MANAGER

Note:-The MAX() function returns the largest value(Salary) of the selected column in table..

select department,MAX(salary) maxsalary from Employee group by Department order by maxsalary asc


Here output of department details and maxsalary details of employee...

department
maxsalary
SALES MANAGER
600000
CA
700000
HR Manager
800000
Sr. Programmer
1000000

D

get  Department wise minimum  salary from employee table order by salary ascending-

Table Name---------Employee
Employee_id
First_name
Last_name
Salary
Joining_date
Department
1
Pankaj
Kumar
1000000
2013-01-01 00:00:00.000
Sr. Programmer
2
Ranchiki
Singh
800000
2013-01-01 00:00:00.000
HR Manager
3
Gaurav
Singh
700000
2013-02-01 00:00:00.000
CA
4
Vijay
Singh
600000
2013-02-01 00:00:00.000
SALES MANAGER

Note:-The MIN() function returns the smallest value(Salary) of the selected column in table..

select department, MIN(salary) minsalary from Employee group by Department order by minsalary asc


Output :Here output department details and minimum salary of employee..

department
minsalary
SALES MANAGER
600000
CA
700000
HR Manager
800000
Sr. Programmer
1000000

E

**Select no of employee joined with respect to year and month from employee table-

Here Table Name---------Employee
Employee_id
First_name
Last_name
Salary
Joining_date
Department
1
Pankaj
Kumar
1000000
2013-01-01 00:00:00.000
Sr. Programmer
2
Ranchiki
Singh
800000
2013-01-01 00:00:00.000
HR Manager
3
Gaurav
Singh
700000
2013-02-01 00:00:00.000
CA
4
Vijay
Singh
600000
2013-02-01 00:00:00.000
SALES MANAGER

Note:The COUNT() function returns the number of rows that matches a specified Place in a record..
Write Sql Query ..
select DATEPART(yyyy,joining_date) joinyear,DATEPART(mm,joining_date)joiningmonth,COUNT(*) totalemp from Employee group by DATEPART(yyyy,joining_date),DATEPART(mm,joining_date)


Output :Here output NO OF EMPLOYEE JOINED WITH RESPECT TO YEAR AND MONTH FROM EMPLOYEE TABLE..

joinyear
joiningmonth
totalemp
2013
1
2
2013
2
2

F

**get department,total salary with respect to a department from employee table where total salary greater than 800000 order by total salary descending-

Here Table Name---------Employee
Employee_id
First_name
Last_name
Salary
Joining_date
Department
1
Pankaj
Kumar
1000000
2013-01-01 00:00:00.000
Sr. Programmer
2
Ranchiki
Singh
800000
2013-01-01 00:00:00.000
HR Manager
3
Gaurav
Singh
700000
2013-02-01 00:00:00.000
CA
4
Vijay
Singh
600000
2013-02-01 00:00:00.000
SALES MANAGER


Note: The where keyword could not be used with aggrigrate function where we use "Having clause".

select department,sum(salary) totalsalary from employee group by Department having SUM(salary)>800000 order by totalsalary desc


Here output :-
department
totalsalary
Sr. Programmer
1000000



G



**Select top 2 salary from employee table-
Table Name---------Employee
Employee_id
First_name
Last_name
Salary
Joining_date
Department
1
Pankaj
Kumar
1000000
2013-01-01 00:00:00.000
Sr. Programmer
2
Ranchiki
Singh
800000
2013-01-01 00:00:00.000
HR Manager
3
Gaurav
Singh
700000
2013-02-01 00:00:00.000
CA
4
Vijay
Singh
600000
2013-02-01 00:00:00.000
SALES MANAGER

select top 2 * from Employee order by Salary desc


Here output :

Employee_id
First_name
Last_name
Salary
Joining_date
Department

1
Pankaj
Kumar
1000000
00:00.0
Sr. Programmer

2
Ranchiki
Singh
800000
00:00.0
HR Manager


















H


**Select top 2nd highest salary from employee table-

Table Name---------Employee
Employee_id
First_name
Last_name
Salary
Joining_date
Department
1
Pankaj
Kumar
1000000
2013-01-01 00:00:00.000
Sr. Programmer
2
Ranchiki
Singh
800000
2013-01-01 00:00:00.000
HR Manager
3
Gaurav
Singh
700000
2013-02-01 00:00:00.000
CA
4
Vijay
Singh
600000
2013-02-01 00:00:00.000
SALES MANAGER

select MIN(salary) from (select top 2 * from Employee) a


Here output:-


No column name

800000

What is ASP.NET? Components of ASP.NET

ASP.Net Definition -It is used for creating web-based applications.ASP.Net is a web development platform provided by Microsoft. ASP.NET i...