question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compilation error when one-way binding an attribute value to a c# string.

See original GitHub issue

Title

Compilation error when one-way binding an attribute value to a c# string.

Minimal repro steps

  1. Create a new Blazor app
  2. Open Index.cshtml and add a private string Test; member in a @functions code block
  3. Add a public string InputText {get; set;} prop in the @functions code block
  4. Add the following input in the html code <input @bind(InputText) class="@Test" />
  5. Try to build the project

Expected result

Code should compile

Actual result

The following error is produced

Error	CS1503	Argument 2: cannot convert from 'string' to 'Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeFrame'	WebApplication1.Client	E:\Desktop\WebApplication1\WebApplication1\WebApplication1.Client\obj\Debug\netstandard2.0\Pages\Index.g.cs	42	Active

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
SteveSandersonMScommented, Mar 29, 2018

OK thanks @miroslavp! Reopening.

Again I think this issue will disappear when we remove @onclick(...) and replace it with onclick=..., but we should keep this issue open until we know for sure.

0reactions
rynowakcommented, Apr 12, 2018

This should be fixed in 0.2 with the new event handler feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compilation error when one-way binding an attribute value ...
Compilation error when one-way binding an attribute value to a c# string. Minimal repro steps. Create a new Blazor app; Open Index.cshtml and ......
Read more >
One Way to Source Binding not working
My source is my menuItem and my source property is "IsEnabled". The value converter is programmed in ConvertBack as this is the section...
Read more >
Compiled bindings - .NET MAUI
To use compiled bindings, the x:DataType attribute must be set to a string literal, or a type using the x:Type markup extension.
Read more >
A Detailed Look At Data Binding in Blazor
In this post, I go into detail about how data binding works in Blazor. I cover one-way binding, two-way binding and the various...
Read more >
Understanding Angular property binding and interpolation
It is a one-way binding method, as values go from the component to the template layer and changes made in the component updates...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found