Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4847

How might I avoid repeat Blazor-generated HTML attributes between conditionally-rendered elements?

$
0
0

In a nutshell, how can I make this code better:

@if( this.OnClick_Async is not null ) {<div component-name="TermDisplay" class="basic"            @onclick=@(async e => await this.OnClick_Async(e))            onmouseover="if(@(this.Term.Context is not null) == true && @(this.Term.Context.Context is not null) == true) { window.DisplayMousePopup(event, `@this.Term.Context.Context.Term`); }">        @this.Term.ToString()</div>} else {<div component-name="TermDisplay" class="basic"            onmouseover="if(@(this.Term.Context is not null) == true && @(this.Term.Context.Context is not null) == true) { window.DisplayMousePopup(event, `@this.Term.Context.Context.Term`); }">        @this.Term.ToString()</div>}

Because the attributes use Blazor, I'm not sure if I can simply cop out with attribute splatting.

Edit: I realize I may be asking the wrong question for the given code, but the main question remains.


Viewing all articles
Browse latest Browse all 4847

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>