Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 153831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:52:15+00:00 2026-05-11T09:52:15+00:00

I have a Page that is associated with a master page. In the master

  • 0

I have a Page that is associated with a master page. In the master page, I put the css links in the head section and I put the jquery script tag and the script that contains the function to toggle the grid, but when it is not working. Looks like it is not even calling showhide when I click on an item.

Here is a snippet of the master page:

<head runat='server'> <title></title> <link href='MainLayout.css' rel='stylesheet' type='text/css' /> <link href='ajaxtab.css' rel='stylesheet' type='text/css' /> <link href='dialog.css' rel='stylesheet' type='text/css' /> <link href='grid.css' rel='stylesheet' type='text/css' /> <link href='pager.css' rel='stylesheet' type='text/css' /> <link href='subgrid.css' rel='stylesheet' type='text/css' /> <script src='jquery-1.3.2.min.js' type='text/javascript'></script>  <script type='text/javascript'>       //master: id of div element that contains the information about master data       //details: id of div element wrapping the details grid       function showhide(master, detail) {           //First child of master div is the image           var src = $(master).children()[0].src;           //Switch image from (+) to (-) or vice versa.           if (src.endsWith('plus.png'))               src = src.replace('plus.png', 'minus.png');           else               src = src.replace('minus.png', 'plus.png');            //Set new image           $(master).children()[0].src = src;            //Toggle expand/collapse                              $(detail).slideToggle('normal');       } </script> <asp:ContentPlaceHolder ID='head' runat='server'>  </asp:ContentPlaceHolder> </head> 

Here is the div that contains the showhide function in the onclick event in the aspx page:

<div class='searchgroup'  id='<%#String.Format('master{0}',Container.DataItemIndex)%>' onclick='showhide(<%#String.Format('\'#master{0}\'',Container.DataItemIndex)%> , <%#String.Format('\'#detail{0}\'',Container.DataItemIndex) %>)'> <asp:Image ID='imgCollapsible'             CssClass='first'             ImageUrl='plus.png'             Style='margin-right: 5px;'            runat='server' />  <span class='searchheader'><%#Eval('Business')%></span> </div> 

Here is html it generates for the master and detail div:

//master div <div class='searchgroup'         id='master0'                                                           onclick='showhide('#master0','#detail0')'>  <img id='ctl00_ContentPanel_gvMaster_ctl02_imgCollapsible'       class='first' src='plus.png'       style='border-width:0px;margin-right: 5px;' />      <span class='searchheader'>ABC</span> </div>  //details div <div id='detail0' class='searchdetail'> <div> <table class='searchgrid'        id='ctl00_ContentPanel_gvMaster_ctl02_gvDtails'> <tr> <th>Status</th> <tr class='searchrow'> <td>2</td> </tr> </table> </div> </div> 

I could not get the JQuery working and I was running out of time, so for now I decided to use the collapsible panel externder from the ajax control toolkit. When I get time, I will investigate the JQuery Issue, Thanks for all your suggestions so far. If anyone has any more, please let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:52:16+00:00Added an answer on May 11, 2026 at 9:52 am

    Your javascript is throwing an error at src.endsWith(‘plus.png’) because there is no built in endsWith function in js. replace that with src.substr(-8) == ‘plus.png’ instead and it works:

    <script type='text/javascript'>       //master: id of div element that contains the information about master data       //details: id of div element wrapping the details grid       function showhide(master, detail) {           //First child of master div is the image           var src = $(master).children()[0].src;           //Switch image from (+) to (-) or vice versa.           if (src.substr(-8) == 'plus.png')               src = src.replace('plus.png', 'minus.png');           else               src = src.replace('minus.png', 'plus.png');            //Set new image           $(master).children()[0].src = src;            //Toggle expand/collapse                              $(detail).slideToggle('normal');       } </script> 

    EDIT – Working example:

    MasterPage.master

    <%@ Master Language='C#' AutoEventWireup='true' %>  <!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>     <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>     <script type='text/javascript'>           //master: id of div element that contains the information about master data           //details: id of div element wrapping the details grid           function showhide(master, detail) {               //First child of master div is the image               var src = $(master).children()[0].src;               //Switch image from (+) to (-) or vice versa.               if (src.substr(-8) == 'plus.png')                   src = src.replace('plus.png', 'minus.png');               else                   src = src.replace('minus.png', 'plus.png');                //Set new image               $(master).children()[0].src = src;                //Toggle expand/collapse                                  $(detail).slideToggle('normal');           }     </script>      <asp:ContentPlaceHolder id='head' runat='server'>     </asp:ContentPlaceHolder> </head> <body>     <form id='form1' runat='server'>     <div>         <asp:ContentPlaceHolder id='ContentPlaceHolder1' runat='server'>          </asp:ContentPlaceHolder>     </div>     </form> </body> </html> 

    Default2.aspx

    <%@ Page Language='C#' MasterPageFile='~/MasterPage.master' AutoEventWireup='true' Title='Untitled Page' %>  <asp:Content ID='Content1' ContentPlaceHolderID='head' Runat='Server'> </asp:Content> <asp:Content ID='Content2' ContentPlaceHolderID='ContentPlaceHolder1' Runat='Server'>     <div class='searchgroup' id='master0' onclick='showhide('#master0','#detail0')'>      <img id='ctl00_ContentPanel_gvMaster_ctl02_imgCollapsible' class='first' src='plus.png' style='border-width:0px;margin-right: 5px;' />      <span class='searchheader'>ABC</span>     </div>      <div id='detail0' class='searchdetail'>         <div>             <table class='searchgrid'                id='ctl00_ContentPanel_gvMaster_ctl02_gvDtails'>                 <tr>                     <th>Status</th>                 </tr>                 <tr class='searchrow'>                     <td>2</td>                 </tr>             </table>         </div>     </div> </asp:Content> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page on my site that uses jquery. In the jquery script
I have web forms page that has 2 controls. A gridview and an associated
I have a page that has fields dynamically loaded via JQuery. It allows a
I have a form that contains a tab canvas. On the second canvas page
I have any number of anchor links on a page that need to execute
I have a page that takes a few minutes to run. When I set
I have a page that, depending on input from a previous page, lists a
I have a page that opens a modal dialog. After the operations done on
I have a page that loads a bunch of scripts to prepopulate dropdowns and
I have a page that displays a list with a of elements with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.