Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im trying to load text using @MvcHtmlString.Create(Url.Action("GetText", "Text", new { urlId ="802e0d33-4349-44e4-85d1-3b892e77598e" })); But the only thing it returns is da/Text/GetText?urlId=802e0d33-4349-44e4-85d1-3b892e77598e; and never gets to the action. I should say that the return string contains html text Like the example below the controller code. Which is the reason i'm using MvcString.Create This is how the action in the controller looks like:

C#
public ActionResult GetText(string urlId)
    {
      SeoText model = new SeoText();
      model.Id = new Guid("802e0d33-4349-44e4-85d1-3b892e77598e");
      SeoText returnModel = this.GetSeoTextByUrl(model);

      return Content(returnModel.Description);
    }


HTML
<h2>Found a bug?</h2>
<p>If you think you have found a bug, you can use the <a href="../develop/bugtracker.php">Tracker</a> to report bugs to the developers.</p>
<p>And here is a simple table for you to play with.</p>
<table border="0">
<tbody>
<tr>
<td>Product</td>
<td>Cost</td>
<td>Really?</td>
</tr>
Posted

1 solution

@Html.Action[^] will create the an url, nothing more. You will need an ajax call to get the content you need.
You could start here: http://automagical.rationalmind.net/2011/03/14/basic-ajax-with-mvc3-razor/[^]
 
Share this answer
 
Comments
mortenstarck 21-Jan-13 10:18am    
Arrhh okay. But is it possible to contact the javascript from MvcHtmlString.Create?
Zoltán Zörgő 21-Jan-13 13:21pm    
You can not. And you need not. MvcHtmlString is just a proper way to create a html encoded string. That's all. You probably need a client action, like a button click, or click on any other element. And you can use jquery to assign and execute the ajax call to the backend - to your controller action. The sample you can see on the link given above.

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