Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# MVC4
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">
<tbody>
<tr>
<td>Product</td>
<td>Cost</td>
<td>Really?</td>
</tr>
Posted 21-Jan-13 4:51am

1 solution

Rate this: bad
good
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: http://automagical.rationalmind.net/2011/03/14/basic-ajax-with-mvc3-razor/[^]
  Permalink  
Comments
mortenstarck at 21-Jan-13 10:18am
   
Arrhh okay. But is it possible to contact the javascript from MvcHtmlString.Create?
Zoltán Zörgő at 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
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 Richard MacCutchan 145
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,712
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2014
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