Pav*_*sta 0 c# asp.net-core blazor
当我单击按钮时,应调用 blazor 组件中的两个函数。尝试使用逗号、分号和括号。什么都行不通。
<div class="col-md-auto"><button type="button" class="btn btn-light btn-sm" @onclick="@SearchTable"@*call two methods SearchTable and SortTable*@>Search</button></div>
Run Code Online (Sandbox Code Playgroud)
下面给出两个函数
@functions{
public void SearchTable()
{
foreach (KeyValuePair<int, SearchCriteria> entry in SearchCritRefs)
{
entry.Value.setSearchCriteria(entry.Key);
}
}
public void SortTable()
{
foreach (KeyValuePair<int, SortCriteria> entry in SortCritRefs)
{
entry.Value.setSortCriteria(entry.Key);
}
}
}
Run Code Online (Sandbox Code Playgroud)
做这样的事情:
<div class="col-md-auto"><button type="button" class="btn btn-light btn-sm"
@onclick="@(() => { SearchTable(); SortTable(); })">Search</button></div>
<div>@message1</div>
<div>@message2</div>
@code{
private string message1;
private string message2;
public void SearchTable()
{
message1 = "SearchTable";
}
public void SortTable()
{
message2 = "SortTable";
}
}
Run Code Online (Sandbox Code Playgroud)
注意:我已经向您展示了如何在触发点击事件时调用两个方法,因为这是您的问题。如果这样编码是明智的,那就完全不同了。
归档时间: |
|
查看次数: |
853 次 |
最近记录: |