Thursday 26 July 2012

Custom paging in SQL Server


CREATE PROCEDURE [ProcedureName]
(
    @CurrentIndex int,
    @PageSize int
)
AS

SELECT * FROM(
          SELECT ROW_NUMBER() over(order by ProductID) AS RowId,
                     Product_Name
          FROM    Products
    )a
WHERE RowId BETWEEN (@CurrentIndex -1) * @TotalPageSize+ 1
                      AND     (@CurrentIndex  * @TotalPageSize )

Self invoking Function in JS


//self invoking function expression
   (function sayHello() {
      alert("hello!");
   })();

This function will automatically triggered on page load


Wednesday 25 July 2012

Bulk upload data in Database


  SqlConnection cn = new SqlConnection ("connection string");
  cn.Open();
  SqlBulkCopy bulkCopy = new SqlBulkCopy(cn);
  bulkCopy.DestinationTableName = "Destination table";
  bulkCopy.BatchSize = 100;
  try
  {
     bulkCopy.WriteToServer(DataTableName);
   }
   catch (Exception ex)
   {
      throw;
   }
   finally
   {
      cn.Close();
      cn.Dispose();
   }


DataTable to be inserted must have same schema as destination table

Wednesday 11 July 2012

Get Letest assembly at runtime


 I have tested for Ajax, it works fine
 
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions"             
                                    
publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design"
                                   
publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
      </dependentAssembly>
    </assemblyBinding>

  </runtime>

CSS Hack


background: gray;        /* standard */
background: pink\9;      /* IE-7 & IE-8 */
*background: green;     /* IE 7 and below */
_background: blue;       /* IE 6 */
*+background: blue       /* of Use only IE7*/


/* Use only Mozilla*/
@-moz-document url-prefix() {
            .mozLabel {width: 2.5% }
        }