I have an MVC controller with an action that gives the string I want my work link string to be named as Returned in Can anyone suggest how to do this in my opinion? I have written the markup code in my view which I thought was able to do the trick, but I think I am wrong.
@if (Request.IsAuthenticated) {string returnstr = @Html action ("_moderpress", "usermessage"); @ HTMLActionLink (Listsist, "Index", "Usermessage")}
An MVC controller with an action that gives a string.
This is a problem. ASP.NET does not have action returns in MVC controller functions, not strings. This is the reason why the HTML Action Helper does not do that, you think it does.
I want my action link to return my string as a name.
You can use a custom assistant instead of a controller action that will return the desired string:
public stable class helpers {public static string GetName (this HtmlHelper html) {// something and .. back "some name"; }} and in your opinion:
@if (Request.IsAuthenticated) {@ Html.ActionLink (Html.GetName ()), "index "," Usermess ")} Or simply create one property on your visual model:
@if (Request.IsAuthenticated) {@ Html. ActionLink (Model.SomeName, "Index", "UserMessage")} And after that is the controller action that is serving this view, just populate the same attribute on the visual model Does.
No comments:
Post a Comment