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

[Blazor] Direct DOM Manipulation with C# #6937

Closed
dotNETSanta opened this issue Jan 22, 2019 · 3 comments
Closed

[Blazor] Direct DOM Manipulation with C# #6937

dotNETSanta opened this issue Jan 22, 2019 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@dotNETSanta
Copy link

dotNETSanta commented Jan 22, 2019

Is your feature request related to a problem? Please describe.

Will it be possible to manipulate DOM from C# code directly without invoking javascript functions?

I thought about basics like that

var elem = document.getElementById("123");

elem.AddOrUpdateStyle("background-color", "red");
elem.AddOrUpdateStyle("height", "150px");
elem.Remove("height");

var boxes = document.getElementsByClassName("box");

foreach (var box in boxes)
{
   if (box.Classes.Contains("hidden"))
   {
      box.AddOrUpdateStyle("display", "none");
      continue;
   }

   box.Value = "";
   box.SetAttribute("placeholder", "Type here...");
}

Is it even achievable?

@Eilon Eilon added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jan 23, 2019
@RemiBou
Copy link
Contributor

RemiBou commented Jan 29, 2019

DOM manipulation si currently not supported by web assembly (WebAssembly/proposals#16 , https://github.com/WebAssembly/design/blob/master/Web.md), so it won't be supported by mono wasm soon. You can do that only using the current state of Blazor : custom component and JS interop.

@danroth27 danroth27 added the area-blazor Includes: Blazor, Razor Components label Feb 6, 2019
@IvanJosipovic
Copy link

I think this issue should be reopened. Razor components should have this ability, even if its done with JS interop under the hood. ElementRef should be extended to support most basic JS functions.

@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@FredyWenger
Copy link

Direct DOM access will be the reason for me to try out Blazor.
This is mandatory for the break-thru of Blazor.

@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 12, 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

7 participants