This is to check the file extension while file uploading, using javascript rather than making user to upload on server and than tell him that he has not selected valid file.
var ID = document.getElementById("<%= fileup.ClientID%>").value; // get id of file upload conrol
if (indexOf("\\") == 1) // check if file is selected
{
if(ID.lastIndexOf("jpg") == -1)
alert("Only jpeg files are allowed")
return;
}
This is one of the most common questions asked for database related questions in interviews. One solution is there. I feel there can be a better solution(in terms of performance issues) but i feel this one is also acceptable. So here it is :
Select Min(Salary) from tbSalary where Salary In(Select top 3 Salary from tbSalary order by salary desc)
Here, I have fetched the 3rd highest record from the salary table. You can replace "3" with the record number you want to get.
Firstly, the inner query runs and orders the salary column in descending order. Than the inner query selects Top 3 records from the ordered list.
Secondly, the outer query fires and select the minimum salary from the list selected by the inner query, which gives the required record.
And that's it, u get the result....
One more thing, if u have a better solution, than do tell me here.....Happy querying.....
Primary Key : Primary Key on a column ensures that no duplicate values are inserted in a column. Also applying primary key ensures null values are not allowed. In terms of indexing, Primary Key enforces Clustered Indexing. It implements the Entity integrity Constraint
Unique Key : Unique is similar to Primary key except that null values are allowed in unique key. Also Non-Clustered indexing is implemented by the unique key constraint.
It implements the Entity integrity Constraint
Foreign Key : Foreign key concept is used to establish relation between two tables of a database . In this relationship , a column which is Primary Key for parent table , is referenced by column of a child table i.e. the two columns are linked to each other. The column which refers the Primary key of parent table , becomes the Foreign key for child table.
A constraint in SQL Server is a way to enforce rules on what kind of data can be added or how data can be modified in SQL Tables. These are basically used to avoid any kind of inconsistencies in the database and can be described as assigning properties to the columns. These constraints are categorized into four main categories :
1. Entity Constraints : It ensures that duplicate data is not inserted into the table. This is done by adding Primary Key constraint which ensures that a column can not have a duplicate value. For ex : To make sure that no value of a column named EmpId in a column is repeated , Primary Key constraint is added.
2. Domain Constraints : These constraints are added to ensure that data being added is within the range and type of the datatype of the column. For example to make sure that no value in a column named EmpID is > 50 , this constraint is used. This type of constraint is implemented using theCheck constraint which makes sure that no value greater than 50 is added in the EmpID column.
3. Refrential Integrity Constraint : This type of constraint is added to make sure that data from a table is not deleted if any of its columns is having relation with another table in the database i.e. any other table is dependent on the parent table. This type of constraint isimplemented by the concept of Foreign Key Constraint. For ex : if a table named tbEmp is having EmpID as Primary Key and is referring to EmpID column (which acts as Foreign Key) of another table named tbDepartment , the Foreign Key Constraint makes sure that no data from parent table tbEmp is deleted until all the underlying values from tbDepartment are deleted.
4. User Defined Constraints : These are some rules defined by users which are not in the above
Joins in SQL are used to retrieve data from two or more tables on the basis of a relationship between the tables. The two tables are normally related to each other on the basis of a Primary Key . Joins are classified into two main categories :
1 Inner Join : An inner join returns all the results for which the columns of the two linking tables match each other. For ex Table1 has Stu_ID , Stu_Name and Table2 has Stu_ID , DeptName . To get Dept Name for each student, we can use following querry using Inner Join.
Select Table1.Stu_Name,Table2.DeptName from Table1 Inner Join Table2 Table1.StuID=Table2.Stu_ID
This will return all the results for two tables for which the Stu_Id of the two tables match with each other. Even if the keyword Inner is not specified, it is taken as Inner Join
2. Outer Join: Outer join in SQL is further classified into two categories ....
(a) Left Outer Join : Left outer join selects all the entries for first table and only those entries of second table for which there is a match between the linked columns. If Left Outer join is applied in above case , the result will be all the entries from Table1 and only the entries from Table2 for which there is a match between the Stu_ID columns of the two columns . It is applied as :Select Table1.Stu_Name,Table2.DeptName from Table1 Left Join Table2 Table1.StuID=Table2.Stu_ID
(b) Right Outer Join : Right outer join selects some entries for first table for which there is a match between the two tables and all the entries of second table even if there is a not a match between the linked columns. If Right Outer join is applied in above case , the result will be all the entries from Table2 and only the entries from Table1 for which there is a match between the Stu_ID columns of the two columns . It is applied as :
Select Table1.Stu_Name,Table2.DeptName from Table1 Right Join Table2 Table1.StuID=Table2.Stu_ID
Code behind technique uses coding technique in which code is placed in separate file with extension as .cs and design in separate file with extension as .aspx while Inline coding places both the code and the design in same page with .aspx extension.
Different langauages in .Net framework like VB and C# use different syntax to declare a data type. For Ex: an integer is declared as int in C# and integer in VB. To avoid any mismatch of these two declaration syntax, a common class System.Int32 has been defined to interpret these. Similarly for other data types like string , datetime , arrays etc , base classes have been defined. These all base classes are derived from a single base type System.Object , which form a system called as Common Type System or C.T.S.
M.S.I.L. stands for Microsoft Intermediate Language. When a programmer writes a program using VB or C# ,the compiler of that language converts it into an Intermediate code or Microsoft Intermediate Language and sends it to CLR which further converts it into native code for the machine. Along with M.S.I.L. , metadata is also generated which is data or information related to the code generated.
It is a boolean
property which returns either true or false. If it is false, it implies that
the Page is loading for the first time otherwise it implies that it is a Post
back request for the page.
The main difference between the two is that, RegisterStartupScript places the script at Bottom of
page and RegisterClientScriptBlock at the Top of
the page.
So what’s the big deal in both these scenarios.
Well, the main use of these two depends upon the situation for which we want to
use.
Take an
example of a javascript function that populates a Textbox using a javascript
function when a page is loaded. If you use the RegisterClientScriptBlock method,
the javascript function will give an error. This is because your script is
placed at the top of the page when it was loaded (when the textbox was not even
created). So how can it find the textbox and populate the values. Sp in this case
RegisterStartupscript should be used.
So use of any of the above function depends upon
type of script.
Sometimes in asp.net , when we run an application , an error occurs. This error shows a default page with error type and its description.This type of page should never be displayed especially to the users as they want an application to be working perfectly allright and as user friendly as possible . To avoid this, we can provide with a customized web page with a message to the user.
To show this page we only need to create a page with a message and add a line of code in our web.config file. Follow these steps and you are done.
1. Create your error message Page with any message like "Sorry for your inconvenience but the page you are trying to access is not available at the moment".
2. Go to web.config and look for "system.web" tag
3. Add the "customErrors" tag between its opening and closing tags and add following attributes for it:
customErrors="On/Off/RemoteOnly" defaultRediret="ErrorPage.aspx"
In case mode is set Off , there is no need to provide with defaultRedirect attribute.
The three modes are described as follows :
1. Off Mode : In this case , whenever an error occurs, the default Error page of ASP.Net is shown both to the remote user and the local user. This is the mode which shows the complete error and by default , this error mode is used.
2. On Mode : In this case, whenever an error occurs , the customized error page we have created is displayed both to the local user and the remote user. In this case , if we do not specify the error page to be used , error page shows how we can enable Remote Mode to view the error.
3. Remote Only : In this case , whenever an error occurs , our customized error page with our Message is displayed to the remote user and default error page is shown to the remote user. This mode is the best as it hides error message from the user and shows it only to the concerned user.
defaultRedirect="ErrorPage.aspx" attribute specifies the page where the user is to be redirected in case of any error . This attribute is added only in case Mode is set to either On or RemoteOnly
Sometimes there is requirement to check special characters in whatever the user types. Instead of increasing load on server by checking for this on Server side , this task can be easily performed on client side using javascript. The following function can be applied for this task

Finally call this function on OnClientClick event of the Button or any event of a control

Now just call this check() function in OnClientClick event of the button and this will check for the blank spaces.
.Net Framework is a platform or collection of tools and languages, used for the development of web based as well as window based applications. .Net framework is mainly comprised of two main components named Base Class Library and Common Langauge Runtime.
1. Base Class Library (BCL): Base class library consists of predefined classes which help in performing various tasks like connectivity with the database, web development, accessing the database,security settings of applications etc. during development of an application. This library of classes is commonly shared by all the languages that are available in the .net framework. Some of these langauges include C#, Visual Basic etc.. Latest version of .Net framework 3.5 supports more than 90 languages.
2. Common Language Runtime (CLR) : This component of .net framework manages the execution of the code written in various langauges . A developer writes his/her code in C# or J#. At compile time , the .net compiler for these languages convert them intoIntermediate Language (IL) or Microsoft Intermediate Language (MSIL). At run time , a component of CLR known as JIT Compilerconverts this code into its native code that can be understood by the operating system. JIT compiler converts only the required code into native code and not whole of the code.
Apart from this , CLR also perform some important tasks which include :
(a) Memory management : It involves allocating required memory for the execution of a program and deallocating the same after the program is completed.
(b) Thread management : It involves managing execution of two or programs or processes running at the same time.
(c) Garbage Collection : This task is performed by garbage collector. Its job is to get back the memory allocated to the objects that will not be used again by the application .
(d) Exception Handling : Exception handling is a method to control the flow of execution of a program when an error occurs. When an error occurs, an exception is said to be raised.