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 5974765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:59:17+00:00 2026-05-22T20:59:17+00:00

I have following markup which is generated dynamically using C# in my asp.net MVC2

  • 0

I have following markup which is generated dynamically using C# in my asp.net MVC2 application. There could be more rows depending on data in database. I have shown two rows. one is view row other is edit row. by default I want ‘view’ row(s) visible and rows with id ‘edit’ will be invisible. I want to use jQuery so that:

  1. on click of toggle link, I want view row invisible and edit row visible
  2. on click of update/cancel images, I want edit row invisible and view rows visible. edit button will cause postback
  3. There can be more than one rows with same id (view or edit), do i need to use class instead of id?
<table>
  <tr id="view">
    <a id="toggle" class="icon-button" href="#">
  </tr>
  <tr id="edit" style="display:none">
    <img id="update" alt="Update" src="/static/images/update.png">
    <img id="cancel" alt="cancel" src="/static/images/cancel.png">
  </tr>
  <tr id="view">
    <a id="toggle" class="icon-button" href="#">
  </tr>
  <tr id="edit" style="display:none">
    <img id="update" alt="Update" src="/static/images/update.png">
    <img id="cancel" alt="cancel" src="/static/images/cancel.png">
  </tr>
</table>

[EDIT]

I used this but it is not working:

<script type="text/javascript">
$(function () {
    $(".icon-button").click(function () {
        alert('I am here');
         $('.view,.edit').toggle();
        return false;
    });

    $(".icon-button-cancel").click(function(){
     alert('I am there');
   $('.view,.edit').toggle();
        return false;
    }
});

Please suggest solution using jQuery/JavaScript or any any other ASP.NET alternative

  • 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-22T20:59:17+00:00Added an answer on May 22, 2026 at 8:59 pm

    So, assuming you make the following changes:

    • Wrap your rows in <td> cells to conform to a table format.
    • Use class names instead of IDs (as I mentioned in a comment, an ID must be unique across the entire page).
    • fix your anchor tags to include some form of text.

    (Some of these may just be becuase you posted a demo snippet, I’m not sure). Then, I made a couple of adjustments like made the cancel a link instead of an image, but an image will work.

    <table>
      <tr class="view">
          <td>
              <a class="toggle" class="icon-button" href="#">Edit</a>
          </td>
      </tr>
      <tr class="edit" style="display:none">
          <td>
              <img class="update" alt="Update" src="/static/images/update.png">
              <a class="cancel" href="#">Cancel</a>
          </td>
      </tr>
      <tr class="view">
          <td>
            <a class="toggle" class="icon-button" href="#">Edit</a>
          </td>
      </tr>
      <tr class="edit" style="display:none">
          <td>
            <img class="update" alt="Update" src="/static/images/update.png">
            <a class="cancel" href="#">Cancel</a>
          </td>
      </tr>
    </table>
    

    Then the following will work (with jQuery):

    $('.toggle').click(function(){
        var $tr = $(this).closest('tr');
        $tr.add($tr.next('.edit')).toggle();
    });
    $('.cancel').click(function(){
        var $tr = $(this).closest('tr');
        $tr.add($tr.prev('.view')).toggle();
    });
    

    DEMO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following markup (which I have no control and must remain as
I have the following markup which is just a small portion of the total
I am totally confused with the following error. I have my application which works
I have the following markup, and I want to make the All radio button
I have the following markup for buttons (can be changed, but I really don't
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,
I have following Code Block Which I tried to optimize in the Optimized section
I have following HTML markup, <div id=subcontent_l> <p> <a href=/membership-packages/><img height=202 width=644 alt= src=http://74.52.72.231/wp-content/uploads/2010/06/banner1.jpg
I have the following markup inside a master page <html xmlns=http://www.w3.org/1999/xhtml > <head runat=server>
I have the following markup on page load: <select name=sel_billing_address></select> After page load that

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.