1

I was trying to do something like this:

<MyComp Opt="new(){ Prop1 = "hi"}" />

and this doesn't compile, I get lots of errors from the source generator/ razor.g.cs files

Seems that the problem is that I'm using " symbol inside a parameter value which is already inside " symbols.

Is there a way to escape this so I could define this object inline ?

1 Answer 1

3

Use parentheses inside an @.

<MyComp Opt="@(new(){ Prop1 = "hi"})" />

or another example:

    <button class="btn btn-primary" @onclick="@(() => OnClickSayMessage("Hello"))">Say Hello</button>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.