C# 基于按钮隐藏/显示节单击
我正在使用Blazor HTML,我有一个C# 基于按钮隐藏/显示节单击,c#,blazor,visibility,C#,Blazor,Visibility,我正在使用Blazor HTML,我有一个,其中包含一个表单,我只想向那些单击“是”选项的人显示,我想在默认情况下隐藏该表单。这是我的密码: <h5 class="stath5"><span class="badge badge-secondary">5.</span> Business / Custom Work / Services</h5> <p c
,其中包含一个表单,我只想向那些单击“是”选项的人显示,我想在默认情况下隐藏该表单。这是我的密码:
<h5 class="stath5"><span class="badge badge-secondary">5.</span> Business / Custom Work / Services</h5>
<p class="forPurpose">For tax purposes</p>
<p class="statp">Do you (or a non-member on your land) have business sales, custom work, or services of $10,000 a year or more yearly turnover?</p>
<label class="label-yes">
<input type="radio" class="option-input radio" name="example"/>
Yes
</label>
<label>
<input type="radio" class="option-input radio" name="example" />
No
</label>
@*If yes, display the following; if no, do not @* *@
<section class="showContent">
<p class="statp">Please specify the amount for which you have <span class="badge badge-danger">not</span> yet paid tax:</p>
<EditForm Model="@businessData" style="max-width:800px;" onkeydown="javascript: DisableEnterKey();">
<FluentValidator />
<div class="individualForms">
<label class="statlabel" for="businessReselling"> Business / Reselling:</label><br />
<InputNumber id="businessReselling" class="input" @bind-Value="@businessData.BusinessResellingGross" onwheel="this.blur()" placeholder="$BZ" autofocus />
<ValidationMessage For="() => businessData.BusinessResellingGross" />
</div>
<br /><hr class="statHR" />
<div class="individualForms">
<label class="statlabel" for="pavementTax"> Pavement tax:</label><br />
<InputNumber id="pavementTax" class="input" @bind-Value="@businessData.PavementTaxGross" onwheel="this.blur()" placeholder="$BZ" />
<ValidationMessage For="() => businessData.PavementTaxGross" />
</div>
<br /><hr class="statHR" />
<div class="individualForms">
<label class="statlabel" for="customWrkServices"> Custom Work / Services:</label><br />
<InputNumber id="customWrkServices" for="customWrkServices" class="input" @bind-Value="@businessData.CustomWorkServicesGross" onwheel="this.blur()" placeholder="$BZ" />
<ValidationMessage For="() => businessData.CustomWorkServicesGross" />
</div>
</EditForm>
</section>
5。业务/定制工作/服务
用于税务目的
您(或您所在地区的非会员)是否有年营业额为10000美元或以上的业务销售、定制工作或服务
对
不
@*如果是,显示以下内容;如果没有,请不要@**@
请指定您尚未缴纳税款的金额:
业务/转售:
这可能看起来很简单,但我尝试了一些在线列出的方法,但这些方法并不适用于我的目的。最简单的方法是引入bool变量并将您的
封装在其中:
剃须刀页面:
<label class="label-yes">
<input type="radio" class="option-input radio" name="example" @onchange="OnUpdated"/>
Yes
</label>
@if (ShowSection)
{
<section class="showContent">
...
</section>
}
好的,我对你的回答有个小问题。默认情况下,该部分是隐藏的,但当我单击“是”时,它仍然是隐藏的。您是否调试并查看
e.Value
中是否有任何值?我认为可能没有,因为这似乎是唯一可能出错的地方
public bool ShowSection { get; set; }
public void OnUpdated(ChangeEventArgs e)
{
ShowSection = ((bool)e.Value);
}