Validating button click event using JS from inside ascx nested inside updatepanel
        Posted  
        
            by Viswa
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Viswa
        
        
        
        Published on 2009-08-11T21:17:28Z
        Indexed on 
            2010/05/13
            5:04 UTC
        
        
        Read the original article
        Hit count: 479
        
Hello
I have a button inside an ascx inside an update panel inside aspx content page. When the button is clicked i want it to run a JS function that causes to show a panel. Here is my Code.
    <pre>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ABC.ascx.cs" Inherits="App.ABC" %>
    <script type= "text/javascript" language="javascript">
    var val1=0;
    var val2=0;
    function ShowPanel(val2)
    {
        if(val2 != 0)
        {   
            switch(val2)
            {
            case 1 : 
                document.getElementById('<%=pnl1.ClientID%>').style.visibility = 'visible';
            break;           
            }
        }
        return false;
    }
    </script>
    <asp:LinkButton ID="lbl1" runat="server" OnClick="return ShowPanel(1);">count</asp:LinkButton>
I am not sue how to do this. Please help
Update #1 - ABC.ascx is in updatepanel in the aspx page XYZ.aspx
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ABC.ascx.cs" Inherits="App.ABC" %>
    <script type= "text/javascript" language="javascript">
    var val1=0;
    var val2=0;
    function ShowPanel(val2) {
            if (val2 != 0) {
                switch (val2) {
                    case 1:
                        document.getElementById("<%= this.pnl1.ClientID%>").style.display = "none";
                        break;
                }
            }
            return false;
        }
    </script>
    <div>
    <div style="text-align:center">
    </div>
    <table style="width:100%; text-align:center; border-color:#99CCFF" border="3">
      <tr style="text-align:left">
      <td><asp:LinkButton ID="lbl1" runat="server" OnClientClick="return ShowPanel(1);">count</asp:LinkButton>
      </td>
      <td style="text-align:right"><asp:Button ID="btnHide1" runat="server" Text="hide" 
              Height="18px" Width="32px"/>
      </td>
      </tr>
      <tr>
      <td colspan="2"><asp:Panel ID="pnl1" runat="server" Visible="false"> </asp:Panel>
        </td>
      </tr>
    </table>
    </div>
        © Stack Overflow or respective owner