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

  • Home
  • SEARCH
  • 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 3225236
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:18:58+00:00 2026-05-17T16:18:58+00:00

I have written a web usercontrol (ascx). Inside, there is a Panel that I

  • 0

I have written a web usercontrol (ascx). Inside, there is a Panel that I want to show/hide on click of a hyperlink inside the usercontrol.

Normally, this is easy just by doing something like this (the onclick attribute is added to the hyperlink on prerender):

 var PanelToShow = document.getElementById('<%=PanelInvoiceHasBeenCreated.ClientID %>');

    if (PanelToHide != null) {
        PanelToHide.style.display = 'none';
    }

but because the ascx control is held within the gridview, the above will assess all the controls (of which there are many in the gridview) with the name ‘PanelInvoiceHasBeenCreated’. The only time it will work is when there is 1 row in the gridview. Currently, with my existing code, if I click the hyperlink in any row, it shows/hides the panel in the bottom row of the gridview!

Therefore, my question is how do I get the actual, unique ID I need to show/hide on the correct control in the correct row??????

Thanks in advance.

  • 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. Editorial Team
    Editorial Team
    2026-05-17T16:18:59+00:00Added an answer on May 17, 2026 at 4:18 pm

    You can do this at the rowdatabound event of gridview
    something like this

    write below code at your gridview rowdatabound event

    var usercontrol1=(userControl)e.item.findcontrol("usercontrol1");
    var hyperLink1=(Hyperlink)usercontrol1.FindControl("hyperLink1");
    var PanelInvoiceHasBeenCreated=(Panel)usercontrol1.FindControl("PanelInvoiceHasBeenCreated");
    
    hyperLink1..Attributes.Add("onclick", "javascript:return ShowHidePanel('"+ PanelInvoiceHasBeenCreated.ClientID +"')"); 
    

    And your java script function at your aspx page should be like this

    <script type="text/javascript">
    function ShowHidePanel(panelid)
    {
    
    var PanelToShow = document.getElementById('panelid');
    
        if (PanelToHide != null) {
            PanelToHide.style.display = 'none';
        }
    return false;
    
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited a poorly written web application that seems to have errors when
I have a web application written in C# that consumes several internal web services.
We have a customer that is trying to call our web service written in
I have a web application that was originally written on .Net 1.1 Framework. I
I have written a web app in PHP which makes use of Ajax requests
I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321
I have an asp.net web page written in C#. Using some javascript I popup
I need a little help on this subject. I have a Web application written
I have a web application, written in ColdFusion, which periodically starts using 100% of
I have written an AIR Application that downloads videos and documents from a server.

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.