Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
First I sent my data to controller from view.
@using (Html.BeginUmbracoForm<MyProject.Controllers.searchResultsController>("SearchResults")) { <input type="text" class="inputTypeB cbox04A-01" name="searchText" placeholder="@Umbraco.GetDictionaryValue("Search_v1")" /> <button type="submit" class="cbox04A-02"> <img src="~/Content/Images/icon-search-light.png" /> </button> }
after I get searchtext from controller and find my result. but I cant send that results to view.
I use SurfaceController because I cant catch data when I use RenderMvcController.
public class searchResultsController: SurfaceController { [HttpPost] public ActionResult SearchResults(string searchText) { if (searchText == "") { return CurrentUmbracoPage(); } List<searchResultModel> searchResult = new List<searchResultModel>(); foreach (var result in Umbraco.TypedSearch(searchText, useWildCards: true)) { if (result.TemplateId != 0) { searchResultModel s = new searchResultModel(); s.Name = result.Name; s.Url = result.Url; searchResult.Add(s); } } return View(searchResult); }}
that is my model
public class searchResultModel { public string Name { get; set; } public string Url { get; set; } }
that is SearchResult.cshtml view
@inherits Umbraco.Web.Mvc.UmbracoViewPage<MyProject.Models.searchResultModel> @{ dynamic s = Model; } @foreach (var item in s) { <a href="@item.Url" class="textItem"> <div class="text01 ff-pr-11"> <p><b>@Html.Raw(item.Name)</b></p> </div> <div class="text02 ff-pr-11"> <p>@Html.Raw(item.Url)</p> </div> </a> }
please help me about get data and send data with controller in umbraco
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
how can I send data to view from controller?
First I sent my data to controller from view.
after I get searchtext from controller and find my result. but I cant send that results to view.
I use SurfaceController because I cant catch data when I use RenderMvcController.
that is my model
that is SearchResult.cshtml view
please help me about get data and send data with controller in umbraco
is working on a reply...