locked
How to change the search result into a hypelink? RRS feed

  • Question

  • User89913463 posted

    I have a code written in MVC 5 that reads some data from a collection (a class that contains all the inputs including title, URL,...). I was able to search for the item by its name and return those values. I want to convert each output to a link so that when I click on link it retrieves the data from the collection I already searched. I know the ActionLink creates or redirect to another link. Assume my out put is A, so if I use ActionLink it will create a link with the name that we provide for it (I want to convert that A to the link). Could you please let me know how can I implement this actionlink? If, I need to use actionlink, I need to provide a controller for it. How does that controller knows which items I have returned in my search result before. Assume I have returned titles called A, B and C. I need to have those information and return to my library (that I already searched) and find some other information?

    The last question I have is my search result appears in the default index view. How can I return search results in another view? I need to mention I have to pass the result of my search to my view, something like return View(result), so I cannot put a name of other view inside the ().

    Thanks

    Friday, May 29, 2020 3:18 AM

All replies

  • User-2054057000 posted

    I have is my search result appears in the default index view. How can I return search results in another view? I need to mention I have to pass the result of my search to my view, something like return View(result), so I cannot put a name of other view inside the ().

    You can do like:

    return View("viewname", (object)someobjectname);

    Then in your view you give  model that 'someobjectname' is. I mean if 'someobjectname' is a class person then you add:

    @model Person

    and so on. Hopefully I am able to explain it properly.

    Sunday, May 31, 2020 3:01 PM