Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Get the currentBlock as parameter in method not working

Vote:
 

Greeting. I have a controller for my block containing this:

 public class QuestionBlockController : BlockController
    {
        public override ActionResult Index(QuestionBlock currentBlock)
        {
            return PartialView(currentBlock);
        }

        public void Vote(QuestionBlock currentBlock)
        {
              //Do stuff
        }


The method Vote is invoked through an ajax call, seen in this View for the block:

@Ajax.ActionLink("Vote", "Vote", "QuestionBlock",
                        new AjaxOptions
                        {
                            HttpMethod = "POST"
                        }, new { @class = "btn btn-vote" })


The problem is that when I click the actionlink it invokes the method Vote but currentBlock is null.

If I debug the currentBlock for Index method it is correctly set with the currentBlock as the current BlockData object.

What am I missing?

Regards,

ChrisRun

#141278
Nov 11, 2015 8:56
Vote:
 

try passing currentBlock contentreference in as a parameter value to the ajax request

new AjaxOptions{

    HttpMethod = "POST", currentBlock = Model.ContentLink

}

#141401
Nov 13, 2015 18:52
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.