Pages

Monday, June 20, 2011

How to get browser screen settings and apply it to page controls

You can use the JavaScript, suppose the control type is , see the code below:
  
    
    
    
    
    
    
    
Please remove the control style if it is present.

How to display images with a delay of five seconds

With this script you can see clickable images rotating in real-time without requiring banner rotation software or page reloads/refreshes .You should see a new banner rotating every 5 seconds:
    <%@ Page Language="C#" %>
    
    
    
    
        JavaScript
        
    
    
        
Related posts: http://forums.asp.net/p/1213103/2147140.aspx

How to register the JavaScript function at Code-Behind

Use ResterStartupScript

    this.Page.ClientScript.RegisterStartupScript(this.GetType(),"alert","");

Use Literal control,

    private void Button2_Click(object sender, System.EventArgs e)
    {
        string str;
        str="

Friday, June 3, 2011

T-SQL Queries

There is a table which contains the names like this. a1, a2, a3, a3, a4, a1, a1, a2 and their salaries. Write a query to get grand total salary, and total salaries of individual employees in one query.




SELECT empid, SUM(salary) AS salary
FROM employee
GROUP BY empid WITH ROLLUP
ORDER BY empid

SQL Count Distinct


SQL Count Statement is used to count the total number of records saved in a particular table. SQL Count Statement returns total records including duplicates.
SQL Count (*) Statement does not take any other argument such bas column name to evaluate the result. It counts all columns whether they have duplicates or nulls.
E.g.:
USE NORTHWIND
SELECT COUNT (*) FROM ORDERS

Above SQL Query will return 830.

SQL Count (ALL [Column Name]) Statement returns the number of records including duplicates but excluding null value columns
E.g.:

SELECT COUNT (ALL CUSTOMERID) FROM ORDERS


SQL Count (DISTINCT [Column Name]) Statement returns unique, non null records.
E.g.:
SELECT COUNT (DISTINCT CUSTOMERID) FROM ORDERS


Above SQL Query will return 89.