November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi, have a look at this blog post: https://andrewlock.net/passing-variables-to-a-view-component/
Thanks for the the link.
In Optimizely InvokeAync() only takes a single parameter of type TContentData, How can I add a second or third paramter to that ?
public Task<IViewComponentResult> InvokeAsync(TContentData currentContent)
{
return InvokeComponentAsync(currentContent);
}
//
// Summary:
// Method that component should implement to render currentContent
//
// Parameters:
// currentContent:
// The current content instance.
//
// Returns:
// The result from the com
protected abstract Task<IViewComponentResult> InvokeComponentAsync(TContentData currentContent);
public class XXComponent: AsyncBlockComponent<XXBlock>
{
// This is not possible as InvokeComponentAsync() can only have a single paramter of type TContentData
protected override async Task<IViewComponentResult> InvokeComponentAsync(XXBlock currentContent, string id)
{
var viewModel = new
{
id = id,
currentBlock = currentContent
};
return await Task.FromResult(View(viewModel));
}
// Do you mean like this ?
public async Task<IViewComponentResult> InvokeAsync(XXBlock currentContent, string id)
{
var viewModel = new
{
id = id,
currentBlock = currentContent
};
return await Task.FromResult(View(viewModel));
}
My component class is inheriting from AsyncBlockComponent and by doing so I also have to implement abstract method InvokeComponentAsync() which takes a single paramter of type TContentData.
I have now created a InvokeAsync() with two parameters but which method would be then get called. I would say its InvokeComponentAsync() as mentioned in Optimizely guidelines.
In some of our page views (Razor) we are calling Html extension method
@Html.XXAction(m => m.Id, Model.CurrentBlock.XXBlock)
This is our extension method which works in CMS 11 ->
public static HtmlString XXAction<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression,XXBlock xxBlock)
{
var Id= helper.ClientIdFor(expression).ToString();
var htmlBuilder = new StringBuilder();
htmlBuilder.Append(helper.Action("Index", "XXController",new{xxBlock, Id}));
return HtmlString.Create(htmlBuilder.ToString());
}
Hi,
We are in process of migrating CMS 11 to 12 on .NET 6. In this process we are having some issues concerning block controller. As in our current solution we are having some block controllers index methods som take paramters.
e.g ->
How can this be migrated to AsyncBlockComponent as InvokeComponentAsync doesn't take more than one paramter ?->
Any help would be appreciated