Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more: , +
This is the view :

@foreach (var module in Model)
    {
        if (module.Placeholder == "head")
        {
            
            Html.RenderAction(module.Control, "ContentHtml", module.Content);





        }


        <br />
    }




And this is the controller :

public ActionResult Tabelar2(string content)
      {

              var movies = db.ContentHtmls.Where(s => s.Content.Contains(content));





          return View(movies);
      }



This works only when i set the content 'test1' in the url , example localhost:58881/Home/About/test1 , what I want is how to read the module.Content field into database in this row
Html.RenderAction(module.Control, "ContentHtml", module.Content);
, and then pass that value into the controller
public ActionResult Tabelar2(string content)
, so it can show only the News with that content. This line
Html.RenderAction(module.Control, "ContentHtml", module.Content);
goes to ContentHtml controller , to the certain Action based on module.Control , in this case Tabelar2 , and the route values should be the module.Content.

What I have tried:

I just explained the problem above
Posted
Updated 4-Sep-17 0:33am

1 solution

You need to encapsulate the POST BACK data in a FORM.

HTML
@using (Html.BeginForm()) {
    <p>
        <!-- Fields to post back go here -->
        <input type="submit" value="Delete" /> |
    </p>
}

More info here:
* FormExtensions.BeginForm Method (HtmlHelper) (System.Web.Mvc.Html)[^]
* ASP.NET MVC 4 Helpers, Forms and Validation | Microsoft Docs[^]
* asp.net mvc - How does @Html.BeginForm() works? - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900