Click here to Skip to main content
13,139,254 members (87,458 online)
Rate this:
Please Sign up or sign in to vote.
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:

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);

<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">
Posted 21-Jan-13 3:51am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

@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:[^]
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100