ASP.NET (35) SQL (25) JAVASCRIPT (24) HTML (14) STYLE SHEET (6) ASP (4) SCRIPT (1)

Search me out HERE!!

How to get SMALL icon on Tab when we Browse our Site.

This is FAVICON Icon. You just need to create this icon, with Extention .ico Then include below code in Head Tag. You will get Small Icon which you see on TAB when we Browse any website.

< link rel="shortcut icon" href="favicon.ico" />
YOU CAN ALSO USE .gif or .jpg IMAGE, BUT MAKE SURE THAT ITS SIZE IS SMALL (16 * 16)  

FIND DIFFERENCE BETWEEN TWO DATES IN HOURS, MINUTES, SECONDS..

This query will help you to find out difference between two dates in Hours, Minutes, Seconds in SQL Server.


DECLARE @First datetime
DECLARE @Second datetime
SET @First = '04/17/2008 08:00:00'
SET @Second = getdate()

SELECT DATEDIFF(hour,@First,@Second) as TotalHours,
DATEDIFF(minute,@First,@Second) - (DATEDIFF(hour,@First,@Second) * 60) as TotalMinutes,
DATEDIFF(second,@First,@Second) - (DATEDIFF(minute,@First,@Second) * 60) as TotalSeconds

Confirm delete for GridView's CommandField using JavaScript

This CODE will help you to implement Confirm (Using Javascript) When click on DELETE in GRIDVIEW

For this you need to use asp:linkbutton

CODE For Gridview in test.aspx file is

<asp:gridview id="gv_test" onrowdatabound="gv_test_OnRowDataBound" runat="server" >

< columns >
< asp:templatefield headertext="Delete" >
< itemtemplate >

< asp:linkbutton commandargument='<%# Eval("id") %>' commandname="cmdDelete" id="btnDelete" onclientclick="javascript: return confirm('do u want to delete this record')" runat="server" >  DELETE  </ asp:linkbutton >

</ itemtemplate >
</ asp:templatefield >
</ columns >


CODE for  gv_test_OnRowDataBound Method in test.aspx.cs File is

protected void GridView1_RowCommand(object sender,  GridViewCommandEventArgs e)
    { 

//Through command  Name link Button will be identified.
        if (e.CommandName == "cmdDelete")
        {
            // This is id which you can use for DELETE purpose.
            string id = e.CommandArgument;
                       
        }
    }


Using above code you can get confirm before Delete in GRIDVIEW as given below:



How to get inserted ID after we fire INSERT Query.

Here is the solution which will give you ID of record which is recently inserted in SQL.

select @@identity as id

You can check this Query after INSERT statement. So you will get the ID of new row inserted.

Set OPACITY of image / Div tag.

Set OPACITY of image/Div tag.

~  for IE ~
filter:alpha(opacity=60);
~ CSS standard ~
  opacity:0.6;

 Consider below example:

<img src="test.jpg" width="150" height="113" alt="Opacity Test"
style="opacity:0.4;filter:alpha(opacity=40)" />


Regular Image:


The same image with transparency:

Get LOG value of any Number with any Base

Here is JavaScript Code which will help you to get Logarithm Value of any Number with Any Base.

Consider below code

Alert(Math.log(2)/Math.log(10));

NOTE: Here 2 is Number & 10 is Base.

Above code will give Log 2 Value with Base 10

Play VIDEO in ASP.net With C#

Here is the code which will help you to play video in ASP.net using C#

Just open your design page.
default.aspx

Put below code in it:

<object height="150px" width="200px" type ="video/x-ms-wmv" >
<param name="src" value="movie/test.wmv" />
<param name="AutoStart" value="False" />
</object>



Here test.wmv is the video which you want to play.

Your Output Will be:

Stop Further Execution in ASP.net (with C#)

Question : How to stop further execution in ASP.net in page_load, button_click, or any other method.

Answer:
return;

Just put return wherever you want to stop execution. The control will return back and your page will not be further executed.