Monday 30 July 2012

Resize Table Column in Run Time




How to Resize Table Column in Run Time in asp.net






<%@ Page Language="C#" AutoEventWireup="true" CodeFile="resizingtablecolumn.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<style>
   
h1, h2

{
         
font-family:Verdana, Arial, Helvetica, sans-serif;
 font-size:13px;

}

.move
{
 width:100%;
 background-color:#99CCFF;
 border-bottom:1px solid blue;
 font-size:14px;
 font-family:vardana;
 font-color:"#33CCAA";
 text-align:center;
}

.info
{
 width:100%;
 background-color:#99CCFF;
 border-top:1px solid blue;
 font-size:13px;
 font-family:vardana;
 font-color:"#33CCAA";
}

.panel2{
 width:150; position:absolute; border:1px solid blue; left:500; top:200; font-size:13px; font-family:vardana;}

.panel{
 width:150; position:absolute; border:1px solid blue; left:350; top:200; font-size:13px; font-family:vardana;}
.panel a:visited{color:blue;}
.panel a{text-decoration:none;color:blue}
.panel a:hover{text-decoration:none;}

#panel a.visited{
text-decoration:none;
}

.menu
{
 width:100%;
 background-color:lightyellow;
 font-size:13px;
 font-family:vardana;
}
</style>

<script  type="text/javascript">


    function getSize(name) {
        op = document.getElementById(name).style.width;
    }
    N = (document.all) ? 0 : 1;
    var ob;
    var over = false;
    var over_id = "";

    function MD(e) {
        MOUSTSTART_X = event.clientX;
        MOUSTSTART_Y = event.clientY;
        if (over) {
          
            if (N) {
                ob = document.getElementById(over_id);
                X = e.layerX;
                Y = e.layerY;
                return false;
            }

            else {
                ob = document.getElementById(over_id);
                ob = ob.style;
                ob2 = document.getElementById("maintbl");
                ob2 = ob2.style;
                obwidth = parseInt(ob.width);
                obwidth2 = parseInt(ob2.width);
                X = event.offsetX;
                Y = event.offsetY;
            }
        }
    }

    function MM(e) {

        if (ob) {
            if (N) {
                ob.style.top = e.pageY - Y;
                ob.style.left = e.pageX - X;
            }
            else {
                st = event.clientX - MOUSTSTART_X + obwidth;
                st2 = event.clientX - MOUSTSTART_X + obwidth2;

                if (st >= 30) {
                    ob.width = st;
                    ob2.width = st2;

                }
                return false;
            }
        }
    }

    function MU() {

        ob = null;
    }

    if (N) {
        document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
    }

    document.onmousedown = MD;
    document.onmousemove = MM;
    document.onmouseup = MU;

</script>

</head>

<body>

<h1>RESIZABLE TABLE COLUMN</h1>
<table border="1" style="width:500px; overflow:hidden" id="maintbl">


<tr>

<th id="pnl0"  class='move' onmouseover="over=true;over_id='pnl0'" onmouseout='over=false;' style='width:110px; cursor:e-resize; overflow:hidden'>Column-1 Data</th>

<th id="pnl1"  class='move' onmouseover="over=true;over_id='pnl1'" onmouseout='over=false;' style='width:110px; cursor:e-resize; overflow:hidden'>Column-2 Data</th>

<th id="pnl2"  class='move' onmouseover="over=true;over_id='pnl2'" onmouseout='over=false;' style='width:110px; cursor:e-resize; overflow:hidden'>Column-3 Data</th>

<th id="pnl3"  class='move' onmouseover="over=true;over_id='pnl3'" onmouseout='over=false;' style='width:110px; cursor:e-resize; overflow:hidden'>Column-4 Data</th>

<th id="pnl4"  class='move' onmouseover="over=true;over_id='pnl4'" onmouseout='over=false;' style='width:110px; cursor:e-resize; overflow:hidden'>Column-5 Data</th>

</tr>

<tr>
<td>cell no.1_0</td>
<td>cell no.1_1</td>
<td>cell no.1_2</td>
<td>cell no.1_3</td>
<td>cell no.1_4</td>
</tr>

<tr>
<td>cell no.2_0</td>
<td>cell no.2_1</td>
<td>cell no.2_2</td>
<td>cell no.2_3</td>
<td>cell no.2_4</td>
</tr>

<tr>
<td>cell no.3_0</td>
<td>cell no.3_1</td>
<td>cell no.3_2</td>
<td>cell no.3_3</td>
<td>cell no.3_4</td>
</tr>

<tr>
<td>cell no.4_0</td>
<td>cell no.4_1</td>
<td>cell no.4_2</td>
<td>cell no.4_3</td>
<td>cell no.4_4</td>
</tr>
</table>
</body>
</html>

Sunday 29 July 2012

How to Create Tab Container with Java script


How to create HTML Tab Container with Java Script....................................
                               



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="tab_container.aspx.cs" Inherits="tab_container" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .style1
        {
            width: 2%;
            height: 51px;
        }
    </style>
</head>
<body onload ="onloadtab('div1','div2','div3','div4');">
    <form id="form1" runat="server" >
    <div>
        <table width ="600"  cellpadding="0px" cellspacing="0px" style="height:600px;">
        <tr>
        <td id="div1a"
                style="border-left:1px solid black; border-top:1px solid black; background-color:White; color :Blue;  "
                align="center" class="style1">
        <a href ="javascript:void(0)"  id="div1b" 
                style ="text-decoration:none;  color :Blue; font-weight: 700;"  
                onclick="divtab('div1','div2','div3','div4'); "
                onmouseover="onmousedivtab('div1');" onmouseout="onmouseoutdivtab('div1');">Home</a></td>
       <td id="div2a"
                style="border-top: solid 1px black;  background-color:blue; color :White; "
                align="center" class="style1">
           <b>
       <a href ="javascript:void(0)" id="div2b" style ="text-decoration:none; color :White;"  onclick="divtab('div2','div1','div3','div4');" onmouseover="onmousedivtab('div2');" onmouseout="onmouseoutdivtab('div2');">About Us</a></b></td>
        <td id="div3a"
                style="border-top: solid 1px black; background-color:blue; color :White;   "
                align="center" class="style1">
        <a href ="javascript:void(0)" id="div3b"
                style ="text-decoration:none; color :White; font-weight: 700;"
                onclick="divtab('div3','div2','div1','div4');"
                onmouseover="onmousedivtab('div3');" onmouseout="onmouseoutdivtab('div3');">Services</a></td>
       <td id="div4a"
                style="border-top: solid 1px black; border-right:solid 1px black; background-color:blue; color :White;   "
                align="center" class="style1">
       <a href ="javascript:void(0)" id="div4b"
               style ="text-decoration:none; color :White; font-weight: 700;"
               onclick="divtab('div4','div2','div3','div1');"
               onmouseover="onmousedivtab('div4');" onmouseout="onmouseoutdivtab('div4');">Contact Us</a></td>
       
       
        </tr>
        <tr >
        <td colspan ="4">
         <div id="div1" style="display:block;"><h1>Home</h1>
        </div>
        <div id="div2" style="display:none;"><h1>About Us</h1>
        </div>
        <div id="div3" style="display:none;"><h1>Services</h1>
        </div>
        <div id="div4" style="display:none;"><h1>Contact Us</h1>
        </div>
       
       
        </td></tr>
       
       
        </table>
    </div>
    </form>

ß--- javascript function ---à
    <script type="text/javascript" language="javascript">
        
        var oldbgcolor1 = "white", oldtextcolor1 = "Red";
        var oldbgcolor2 = "blue", oldtextcolor2 = "white";
      
       
       
       
       
        
        function onloadtab(id1,id2,id3,id4) {
           
            var tab1 = id1 + 'a';
            var anch1 = id1 + 'b';
            var tab2 = id2 + 'a';
            var anch2 = id2 + 'b';
            var tab3 = id3 + 'a';
            var anch3 = id3 + 'b';
            var tab4 = id4 + 'a';
            var anch4 = id4 + 'b';
            oldbgcolor1 = "Red";
            oldtextcolor1 = "White";
            oldbgcolor2 = "blue";
            oldtextcolor2 = "white";
          
            document.getElementById(tab1).style.background =oldbgcolor1;
            document.getElementById(anch1).style.color = oldtextcolor1;
            document.getElementById(tab2).style.background = oldbgcolor2;
            document.getElementById(anch2).style.color = oldtextcolor2;
            document.getElementById(tab3).style.background = oldbgcolor2;
            document.getElementById(anch3).style.color = oldtextcolor2;
            document.getElementById(tab4).style.background = oldbgcolor2;
            document.getElementById(anch4).style.color = oldtextcolor2;
        }
        function onmouseoutdivtab(id1) {
           
            var tab1 = id1 + 'a';
            var anch1 = id1 + 'b';
            document.getElementById(tab1).style.background = oldbgcolor1;
            document.getElementById(anch1).style.color = oldtextcolor1;

        }
        function onmousedivtab(id1) {
          
          
            var tab1 = id1 + 'a';
          
            var anch1 = id1 + 'b';
            oldbgcolor1 = document.getElementById(tab1).style.background;
            oldtextcolor1 = document.getElementById(anch1).style.color;
            document.getElementById(tab1).style.background = "REd";
            document.getElementById(anch1).style.color = "white";
        }
       
        function divtab(id1, id2, id3, id4) {

            var tab1 = id1 + 'a';
            var tab2 = id2 + 'a';
            var tab3 = id3 + 'a';
            var tab4 = id4 + 'a';
            var anch1 = id1 + 'b';
            var anch2 = id2 + 'b';
            var anch3 = id3 + 'b';
            var anch4 = id4 + 'b';
            document.getElementById(id1).style.display = "block";
            document.getElementById(id2).style.display = "none";
            document.getElementById(id3).style.display = "none";
            document.getElementById(id4).style.display = "none";
            oldbgcolor1 = "Red";
            oldtextcolor1 = "White";
            oldbgcolor2 = "blue";
            oldtextcolor2 = "white";
           
            document.getElementById(tab1).style.background = oldbgcolor1;
            document.getElementById(tab2).style.background = oldbgcolor2;
            document.getElementById(tab3).style.background = oldbgcolor2;
            document.getElementById(tab4).style.background = oldbgcolor2;
            document.getElementById(anch1).style.color = oldtextcolor1;
            document.getElementById(anch2).style.color = oldtextcolor2;
            document.getElementById(anch3).style.color = oldtextcolor2;
            document.getElementById(anch4).style.color = oldtextcolor2;
           
        }
    </script>
</body>
</html>