C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,307 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm trying to initiate the following code. There are no errors showing. But these await actions don't work. Can anyone kindly help me to solve this?
private async void TableI_Click(object sender, RoutedEventArgs e)
{
MainWindow mainwin = (MainWindow)Window.GetWindow(this);
List<TblICell> Data = TableIData();
foreach (TblICell item in Data)
{
switch (item.CellID)
{
case 0:
await mainwin.MetaWebView.ExecuteScriptAsync($"document.getElementById('Table1_SecurityTitle'" + item.RowID + ").value='" + item.CellVal + "'");
await mainwin.MetaWebView.ExecuteScriptAsync($"document.getElementById('Table1_SecurityTitleFootnote'" + item.RowID + ").value='" + item.FNVal + "'");
break;
case 1:
await mainwin.MetaWebView.ExecuteScriptAsync($"document.getElementById('Table1_AmountBeneficiaryOwned'" + item.RowID + ").value='" + item.CellVal + "'");
await mainwin.MetaWebView.ExecuteScriptAsync($"document.getElementById('Table1_AmountBeneficiaryOwnedFootnote'" + item.RowID + ").value='" + item.FNVal + "'");
break;
case 2:
await mainwin.MetaWebView.ExecuteScriptAsync($"document.getElementById('Table1_OwnershipForm'" + item.RowID + ").value='" + item.CellVal + "'");
await mainwin.MetaWebView.ExecuteScriptAsync($"document.getElementById('Table1_OwnershipFormFootnote'" + item.RowID + ").value='" + item.FNVal + "'");
break;
case 3:
await mainwin.MetaWebView.ExecuteScriptAsync($"document.getElementById('Table1_OwnershipNature'" + item.RowID + ").value='" + item.CellVal + "'");
await mainwin.MetaWebView.ExecuteScriptAsync($"document.getElementById('Table1_OwnershipNatureFootnote'" + item.RowID + ").value='" + item.FNVal + "'");
break;
}
}
}
What does not work mean? It looks like you are trying to execute some JavaScript, but they all have syntax errors. You are appending the rowId after the closing quote in the getElementById
Try
private async Task
TableI_Click(object sender, RoutedEventArgs e)
Never use void with awaiting a task.