title: How to pass id to asp-route-id on the modal button
body: <p>I have a problem with my code. I have table with 3 columns: category, subcategories and actions. In third column I keep buttons &quot;Edit&quot; and &quot;Delete&quot;. Below part of my code:</p>
  <pre><code>&lt;tbody&gt;
          @foreach (var category in Model.ToList())
          {
  
              &lt;tr&gt;
                  &lt;td class=&quot;hide&quot;&gt;@category.Id&lt;/td&gt;
                  &lt;td&gt;@category.Name&lt;/td&gt;
                  &lt;td&gt;
                      @if (category.Subcategories != null)
                      {
                          @foreach (var subcategory in category.Subcategories.ToList())
                          {
                              &lt;p&gt;@(subcategory.Id + &quot;. &quot; + @subcategory.Name)&lt;/p&gt;
  
                          }
  
                      }
                      else
                      {
                          &lt;a class=&quot;btn btn-primary&quot; style=&quot;width:auto&quot;
                             asp-controller=&quot;administrator&quot;
                             asp-action=&quot;CreateSubcategory&quot;&gt;
                              Dodaj podkategorię
                          &lt;/a&gt;
                      }
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;a class=&quot;btn btn-primary&quot;
                         asp-controller=&quot;administrator&quot;
                         asp-action=&quot;EditCategory&quot;
                         asp-route-id=&quot;@category.Id&quot;&gt;
                          Edytuj
                      &lt;/a&gt;
                      &lt;button type=&quot;button&quot; onclick=&quot;getId(this.data-id)&quot; class=&quot;btn btn-primary&quot; data-toggle=&quot;modal&quot; data-target=&quot;#myModal&quot; data-id=&quot;@category.Id&quot;&gt;
                          Usuń
                      &lt;/button&gt;
  
                  &lt;/td&gt;
              &lt;/tr&gt;
          }
      &lt;/tbody&gt;
  </code></pre>
  <p>When button &quot;Usuń&quot; will be clicked I want show modal window. And this is ok:</p>
  <pre><code>&lt;div id=&quot;myModal&quot; class=&quot;modal&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot;&gt;
  &lt;div class=&quot;modal-dialog&quot; role=&quot;document&quot;&gt;
      &lt;div class=&quot;modal-content&quot;&gt;
          &lt;div class=&quot;modal-header&quot;&gt;
              &lt;h5 class=&quot;modal-title&quot;&gt;Usuwanie kategorii&lt;/h5&gt;
              &lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&gt;
                  &lt;span aria-hidden=&quot;true&quot;&gt;&amp;times;&lt;/span&gt;
              &lt;/button&gt;
          &lt;/div&gt;
          &lt;div class=&quot;modal-body&quot;&gt;
              &lt;p&gt;Czy na pewno chcesz usunąć kategorię ?&lt;/p&gt;
          &lt;/div&gt;
          &lt;div class=&quot;modal-footer&quot;&gt;
              &lt;form method=&quot;post&quot;&gt;
                  &lt;button id=&quot;modalDeleteButton&quot; type=&quot;submit&quot; class=&quot;btn btn-primary&quot;
                          asp-controller=&quot;administrator&quot;
                          asp-action=&quot;DeleteCategory&quot;&gt;
                      Usuń
                  &lt;/button&gt;
              &lt;/form&gt;
              &lt;button type=&quot;button&quot; class=&quot;btn btn-secondary&quot; data-dismiss=&quot;modal&quot;&gt;Anuluj&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And finally in modal window user have a two choice - close modal window or &quot;Delete&quot; category. In this place I have to know which row was clicked before modal was showing. How to pass @category.Id to my modal window button &quot;Usuń&quot; and set asp-route-id?</p>
  <p>Below my JS/JQuery code:</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
  $(&quot;#myModal&quot;).on('show.bs.modal', function (event) {
      $(event.currentTarget).find('asp-route-id').val(getId);
  });
  
  function getId(clicked_id) {
      return clicked_id;
  }
  </code></pre>
  
  <p>Now I have got return url https://localhost:80888/Administrator/DeleteCategory - without &quot;/7&quot; where 7 is Id.</p>