Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditorTemplateView option does not accept PartialAsync() method #8070

Closed
kendo-bot opened this issue Dec 3, 2024 · 1 comment
Closed

EditorTemplateView option does not accept PartialAsync() method #8070

kendo-bot opened this issue Dec 3, 2024 · 1 comment
Assignees
Labels
Milestone

Comments

@kendo-bot
Copy link
Collaborator

kendo-bot commented Dec 3, 2024

Bug report

When loading an editor through a partial View using EditorTemplateView(await Html.PartialAsync("PartialViewName")), the following error occurs:

The 'await' operator can only be used within an async lambda expression. Consider marking this lambda expression with the 'async' modifier.

Reproduction of the problem

@(Html.Kendo().Form<UserViewModel>()
     .Name("myForm")
     .Items(items =>
     {
         items.Add().Field(f => f.Username).EditorTemplateView(await Html.PartialAsync("PartialViewName"));
      })
)

Expected/desired behavior

The EditorTemplateView() must accept Html.PartialAsync("PartialViewName").

Environment

  • **Telerik UI for ASP.NET Core version: 2024.4.1112
  • **Browser: [all]
@kendo-bot kendo-bot added the FP: Unplanned Sync status with associated Feedback Item label Dec 3, 2024
@alestoya alestoya self-assigned this Feb 24, 2025
@alestoya alestoya added this to the 2025 Q2 (May) milestone Feb 24, 2025
@github-actions github-actions bot added FP: Planned Sync status with associated Feedback Item and removed FP: Unplanned Sync status with associated Feedback Item labels Feb 24, 2025
@alestoya alestoya added FP: In Development Sync status with associated Feedback Item and removed FP: Planned Sync status with associated Feedback Item labels Feb 26, 2025
@alestoya
Copy link

Conclusion

Closing this after further discussion. Such functionality would inevitably require introducing an asynchronous piece of logic within a synchronous method. This poses a risk in terms of how the underlying threading mechanism for the framework handles this situation.

Adding such a feature would inevitably place the UI thread in a predicament, as it may produce:

  • Deadlocks
  • Thread pool Exhaustion
  • Impede the overall UX experience

There are several topics that discuss this in a more comprehensive manner:

Workaround

It is possible to use a code block, await the call to Html.PartialAsync and pass the result to the EditorTemplateView:

@{
    var myTemplate = await Html.PartialAsync("PartialViewName");
}

@(Html.Kendo().Form<UserViewModel>()
     .Name("myForm")
     .Items(items =>
     {
         items.Add().Field(f => f.Username).EditorTemplateView(myTemplate);
      })
)

@github-actions github-actions bot added FP: Completed Sync status with associated Feedback Item and removed FP: In Development Sync status with associated Feedback Item labels Mar 20, 2025
@alestoya alestoya added FP: Declined Sync status with associated Feedback Item S: Wrappers (ASP.NET MVC) S: Wrappers (ASP.NET Core) and removed Bug SEV: Low S: Wrappers (ASP.NET Core) C: Form FP: Completed Sync status with associated Feedback Item labels Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants