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

Search me out HERE!!

Refreshing parent window from child window

Below Javascript is used to refresh PARENT window from CHILD window, also CHILD window will be closed.

//Call below Javascript on CLOSE button click in CHILD window
JAVASCRIPT FUNCTION:

function change_parent(){
window.opener.location.href="http:yahoo.com";
self.close();
}
 

Now call this Javascript on your button
onClick="change_parent();"

You will see that when you close your child window your parent page will redirect to 'yahoo.com' 

HOW TO USE CASE IN SQL SERVER 2005

Below is syntax to use CASE in SQL Server 2005

Syntax:
SELECT
CASE
    WHEN CONDITION THEN
            DATA                  
        ELSE
            DATA
    END AS column_name
FROM tableName


Example:
SELECT
CASE
        WHEN SIGN(DATEDIFF(dd,GETDATE(),any_date)) = '1' THEN
            DATEDIFF(dd,GETDATE(),any_date)                  
        ELSE
            SIGN(0)
    END AS column_name
FROM any_table 


Note : You can use number of WHEN condition before ELSE

SHOW ROW NUMBER IN GRIDVIEW

Below code is used in .aspx file to get ROW NUMBER in gridview.

<asp:TemplateField HeaderText="No.">
                    <ItemTemplate>
                      
<center><%# Container.DataItemIndex + 1 %></center>
                    
</ItemTemplate>
</asp:TemplateField>



E-MAIL VALIDATION USING JAVASCRIPT

Below javascript is used to valid email address using Regular Expression.
function validate()
{
   //Here 'form1' is name of form. & 'email' is name of Email Text box.
   var address = document.form1.email.value;
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(address) == false) {
              alert('Invalid Email Address');
              document.form1.email.focus();
              return false;
            }

   return true;
}

How to find ROW in Dataset / Applying PRIMARY KEY to Dataset

Here is solution how you can apply primary key to your DATASET & using that how can you find particular row from Dataset using that Primary Key.

Note the below given code:

DataSet ds = new DataSet();
DataColumn[] dc = new DataColumn[1];  
//HERE '1' SPECIFY NO. OF PRIMARY KEY. YOU CAN HAVE MORE THEN 1 PRIMARY KEY.
dc[0] = ds.Tables[0].Columns["id"];  //id is Primary Key
ds.Tables[0].PrimaryKey = dc;


Now you can get ROW as given below:

DataRow dr = ds.Tables[0].Rows.Find("1"); 

//Here "1" Specify Primary key.. i.e. Here output will be row whose id=1.

How to Get ROUND BOX in Website Designing.

Kindly see the below images. To get the round box you need to CUT box into various pieces as shown in below Image.
HERE I HAVE ALSO SHOWN HOW TO DISPLAY NAME IN BETWEEN. THIS IS OPTIONAL.




Now go with below given code.


CODE:
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td style="background:url(images/top_left.gif); background-repeat:no-repeat; width:19px; height:37px;"></td>
<td style="background:url(images/top_middle.gif); background-repeat:repeat-x; height:37px;" align="left">
<img align="top" src="images/kapil.gif" border="0" height="37px" />
</td>
<td style="background:url(images/top_right.gif); background-repeat:no-repeat; width:19px; height:37px;"></td>
</tr>

<tr>
<td style="background:url(images/middle_left.gif); background-repeat:repeat-y; width:19px; " ></td>
<td>

<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
THIS IS TEXT AREA
</td>
</tr>
</table>

</td>
<td style="background:url(images/middle_right.gif); background-repeat:repeat-y; width:19px; "></td>
</tr>

<tr>
<td style="background:url(images/bottom_left.gif); background-repeat:no-repeat; width:19px; height:20px;"></td>
<td style="background:url(images/bottom_middle.gif); background-repeat:repeat-x; height:20px;"></td>
<td style="background:url(images/bottom_right.gif); background-repeat:no-repeat; width:19px; height:20px;"></td>
</tr>
</table>


After applying this, you will get below given Output: