After clicking on an actionlink, how do I reference back to its linkText?

No Window

Say I have a table that begins like this:

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.ActionLink(item.Name, "Things", new { someId = item.Id})
        </td>

And it takes me to the view for that specific item. Once I am in that separate .cshtml file, how can I reference back to the original "item.Name" string that appeared in this ActionLink?

* SOLUTION EDIT *

The solution ended up looking like this.

The ActionLink:

@Html.ActionLink(item.Name, "Things", new { someId = item.Id, someName = item.Name})

The Action:

public ActionResult Things(Guid? someId, string someName)
...
ViewBag.currentName = someName;

The other View:

<h2>@ViewBag.currentName</h2>
Ivan Gritsenko

I think you don't have to reference to first ActionLink argument. What might interest you is an object which is a Model for this view. When you click the link you will navigate to action where you pass the someId - id of current model object. Then probably you should find an object by its id in your storage. It will have .Name property that was used as ActionLink argument.

However if you just need exactly the same string you've used as a first argument in ActionLink which can be any string you should duplicate it in route values. Your Things action should accept not only someId argument but also this string. After you should pass this string via Model or ViewBag/ViewDictionary to your view.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Clicking the new_photo_path link redirects to login_path .. how do I get back there after?

From Dev

How do I put the HEAD back to its previous position after reset?

From Dev

How do I get my USB back to its original settings after using as a live usb?

From Dev

How do I put the HEAD back to its previous position after reset?

From Dev

How do I make a PageView wrap back to its first page?

From Dev

How do i open a fragment after clicking a Gridview

From Dev

How do I reference a category and use its methods in a class?

From Dev

How do I drop back to the python shell after exiting a script?

From Dev

How do I insert the cursor back into the document after using find?

From Dev

How do I move back to try block after catching exception

From Dev

How do I move back to try block after catching exception

From Dev

After accidentally renaming /etc, how do I rename it back?

From Dev

How do I get my menu back after using .toggle?

From Dev

How do I get back to Unity after using Gnome 3.8

From Dev

How do I drop back to the python shell after exiting a script?

From Dev

After accidentally renaming /usr, how do I rename it back?

From Dev

How do I get back files after "mv * .*"?

From Dev

How do I redirect back to the home page after authentication

From Dev

How do I disable a cascading kendo combobox after its loaded?

From Dev

I click an input radio and change an image src, by clicking again...how do I change the image back how it was?

From Dev

How can I get my changes back after clicking "Undo pending changes..." in Visual Studio 2013 and TFS

From Dev

After clicking on an internal link in a PDF in Adobe Acrobat Pro DC, how can I go back to the location of the text where the link is located?

From Dev

Angularjs - how to load images/videos after clicking on its title

From Dev

How to get id of tr after clicking its td's element?

From Dev

How to hide dropdown div after clicking aside of its parent menu?

From Dev

How can I remove text after clicking?

From Dev

Why does my object lose its resizable attribute and how do I get it back?

From Dev

How do I rotate an image on my server then save it back to to its initial url?

From Dev

How do I fix my USB drive to get its original 8GB size back?

Related Related

  1. 1

    Clicking the new_photo_path link redirects to login_path .. how do I get back there after?

  2. 2

    How do I put the HEAD back to its previous position after reset?

  3. 3

    How do I get my USB back to its original settings after using as a live usb?

  4. 4

    How do I put the HEAD back to its previous position after reset?

  5. 5

    How do I make a PageView wrap back to its first page?

  6. 6

    How do i open a fragment after clicking a Gridview

  7. 7

    How do I reference a category and use its methods in a class?

  8. 8

    How do I drop back to the python shell after exiting a script?

  9. 9

    How do I insert the cursor back into the document after using find?

  10. 10

    How do I move back to try block after catching exception

  11. 11

    How do I move back to try block after catching exception

  12. 12

    After accidentally renaming /etc, how do I rename it back?

  13. 13

    How do I get my menu back after using .toggle?

  14. 14

    How do I get back to Unity after using Gnome 3.8

  15. 15

    How do I drop back to the python shell after exiting a script?

  16. 16

    After accidentally renaming /usr, how do I rename it back?

  17. 17

    How do I get back files after "mv * .*"?

  18. 18

    How do I redirect back to the home page after authentication

  19. 19

    How do I disable a cascading kendo combobox after its loaded?

  20. 20

    I click an input radio and change an image src, by clicking again...how do I change the image back how it was?

  21. 21

    How can I get my changes back after clicking "Undo pending changes..." in Visual Studio 2013 and TFS

  22. 22

    After clicking on an internal link in a PDF in Adobe Acrobat Pro DC, how can I go back to the location of the text where the link is located?

  23. 23

    Angularjs - how to load images/videos after clicking on its title

  24. 24

    How to get id of tr after clicking its td's element?

  25. 25

    How to hide dropdown div after clicking aside of its parent menu?

  26. 26

    How can I remove text after clicking?

  27. 27

    Why does my object lose its resizable attribute and how do I get it back?

  28. 28

    How do I rotate an image on my server then save it back to to its initial url?

  29. 29

    How do I fix my USB drive to get its original 8GB size back?

HotTag

Archive