How to access Javascript variable from Code behind

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elavarasum
    New Member
    • Feb 2007
    • 1

    #1

    How to access Javascript variable from Code behind

    Hi,

    Can any one help me.

    i have created one color pallet. if i click particular color, it will set as background-color of CardTable.

    I want to access the particular set in the CardTable from Code behind file. What is the way to access the color. Here is the sample code

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    
    <html>
    <head>
    <title>Page title</title>
    <script type="text/javascript">
    <!--
    function DesignCard(GetValue)
    {
    	document.getElementById('CardTable').style.backgroundColor  = GetValue;
    }
    //-->
    </script>
    </head>
    <body>
    <asp:Table ID="CardTable" Runat="server" CellPadding="0" CellSpacing="0" Width="600" CssClass="tableborder">
    <asp:TableRow>
    <asp:TableCell ID="Header">
    <asp:label id="LblHeader" runat="server">Hi My Dear</asp:label>
    </asp:TableCell>
    </asp:TableRow>
    </asp:Table>
    
    <a onclick='JavaScript:DesignCard("#FF6600");'>Orange</a>
    
    </body>
    </html>
    Last edited by kenobewan; Feb 21 '07, 12:48 PM. Reason: Add code tags
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Try using attributes.add( ) for the onclick event, you will need a page element that is runat server to initiate it.

    Comment

    Working...