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

Passing arguments to onclick #15956

Closed
alexanderjwoods opened this issue Jun 4, 2018 · 8 comments
Closed

Passing arguments to onclick #15956

alexanderjwoods opened this issue Jun 4, 2018 · 8 comments
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@alexanderjwoods
Copy link

Not sure if this is doable in 0.3.0, but I want to pass arguments to my onclick method like so:

button onclick=@Mymethod(MyParam)

Doing so results in a compile error of "CS 1503 cannot convert from 'void' to 'string'"

@Suchiman
Copy link
Contributor

Suchiman commented Jun 4, 2018

try <button onclick=@(() => Mymethod(MyParam)) />

@SteveSandersonMS
Copy link
Member

Thanks, @Suchiman!

@alexanderjwoods
Copy link
Author

Thanks guys! Side note: So happy you guys are responding so quickly to help requests, but is there a better spot for these? I feel guilty opening issues when they aren't really issues :P

@Suchiman
Copy link
Contributor

Suchiman commented Jun 4, 2018

@alexanderjwoods https://gitter.im/aspnet/Blazor is a quite active place 😉

@danroth27
Copy link
Member

@alexanderjwoods You can also post questions on StackOverflow. That way they can be referenced over time

@alexanderjwoods
Copy link
Author

@Suchiman Awesome! I will post over there unless it is a real bug!
@danroth27 I refuse to post on SO because of their attitude toward beginners. I have had more than one intern tell me they don't like SO because of the condescending nature toward "n00b" questions, and I quite agree. It turns people off to programming at worst, and at best it makes it harder for people to become proficient!

@danroth27
Copy link
Member

Fair enough. I think you'll find the folks on the Blazor Gitter to be very helpful.

@furoraest
Copy link

when doing it within svg got following error:
Uncaught Error: Microsoft.AspNetCore.Blazor.Browser.Interop.JavaScriptException: Cannot set attribute on non-element child
Error: Cannot set attribute on non-element child
at BrowserRenderer.applyEdits (BrowserRenderer.ts:76)
at BrowserRenderer.updateComponent (BrowserRenderer.ts:33)
at renderBatch (Renderer.ts:45)
at Array. (mono.js:1)
at _emscripten_asm_const_iiiiii (mono.js:1)
at wasm-function[2679]:25
at wasm-function[3541]:44
at wasm-function[3548]:408
at wasm-function[3550]:224
at wasm-function[3766]:189
at Microsoft.AspNetCore.Blazor.Browser.Interop.RegisteredFunction.InvokeUnmarshalled[T0,T1,T2,TRes] (System.String identifier, T0 arg0, T1 arg1, T2 arg2) <0x1c21a40 + 0x00054> in <92ed9c6772a34798bccecc99cc26cbcd>:0
at Microsoft.AspNetCore.Blazor.Browser.Interop.RegisteredFunction.InvokeUnmarshalled[T0,T1,TRes] (System.String identifier, T0 arg0, T1 arg1) <0x1c21958 + 0x00022> in <92ed9c6772a34798bccecc99cc26cbcd>:0

@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/blazor Oct 27, 2019
@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Oct 27, 2019
@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

6 participants