Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have following code is running perfect. but when i use master page its not working. So help me. How i use this code in master page. Means i have .aspx page for which i am using master page that time this code is not running.

ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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></title>
    <script type='text/javascript' src='http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js'>
    </script>
<script type="text/javascript">
         $(function () {
             $("#btn1").click(function (evt) {
                 evt.preventDefault();
                 $('#panel1').slideUp('slow');
                 $('#panel2').slideDown('slow');
             });
             $("#Button1").click(function (evt) {
                 evt.preventDefault();
                 $('#panel2').slideUp('slow');
                 $('#panel1').slideDown('slow');
             });
         });
</script>
</head>
<body>
    <form id="form1"  runat="server">
    <div>
        <asp:Panel runat="server" ID="panel1" Style="visibility: visible;">
            <h2>
                This is panel 1</h2>
          
             <input type="button" id="btn1" value="Change Password" />
        </asp:Panel>
        <asp:Panel ID="panel2" runat="server" Style="display: none;">
            <h2>
                This is panel 2.</h2>
          
            <input type="button" id="Button1" value="Cancel" />
        </asp:Panel>
    </div>
    </form>
</body>
</html>
Posted
Updated 17-Jun-15 9:04am
v2

1 solution

Your controls get a different ID client side when using a master page. Just view source and you can see what the client IDs are.

You can also set your client ids in JavaScript by using this syntax:
C#
<![CDATA[<%= uploadResult.ClientID %>]]>


Or you can build it all through C#. I suggest using the first option.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900