少し検索しても、明確な答えが見つかりませんでした。
数字を含む大きな HTML テーブルがあります。$ または日でテーブルを表示したい場合にユーザーがクリックできるセレクター (radiobuttonlist) があります。
現在は完全に機能しますが、ユーザーが 2 つのラジオボタンのいずれかをクリックするたびにコード ビハインド関数 (RefreshTable) を呼び出しているため、ページが更新されます。形式が変更され、RefreshTable 関数によって新しい計算が行われる必要があるためです。
. ajaxなどを使用してページを更新せずにその関数を呼び出す方法はありますか? この関数には 1 つのパラメーターしかありません: ProjectID、VB.NET でコーディングされており、ASP.NET を使用しています。
これは .ASPX ページのテーブル コードです。これはシェルのみです。RadioButton が変更されたとき (autopostback=true) に呼び出される VB.NET メソッドを介してすべてが追加されるため、どれが選択されているかを確認し、VB.NET メソッドを実行します。テーブルに入力します。(関数のコードは以下です)
注:機密情報であるため、一部の列\変数名を変更しましたが、全体像を把握できます。
<td>
<asp:RadioButtonList RepeatDirection="Horizontal" id="rdiolist" onclick="alert('hello');" runat="server" RepeatLayout="flow" AutoPostBack="true">
<asp:ListItem selected="true"> $ </asp:ListItem>
<asp:ListItem> Days </asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</table>
<br />
<table id="tblBudgetRessourceVP" runat="server" class="ProjetTable ProjetTableHover">
<thead>
<tr>
<th style="width:80px">COLUMN 1</th>
<th style="width:120px">COLUMN 2/th>
<th style="width:120px">COLUMN 3</th>
<th style="width:120px">COLUMN 4</th>
<th style="width:120px">COLUMN 5</th>
<th style="width:120px">COLUMN 6</th>
<th style="width:120px">COLUMN 7</th>
<th style="width:120px">COLUMN 8</th>
</tr>
</thead>
</table>
コード ビハインド メソッドは、ポストバックなしで呼び出したいものです。すべてのページ更新を削除したいと考えています。関数のサンプルを投稿します。これは、すべての列に対して実行されるため、非常に反復的であるためです。かなり機密性の高いデータであるため、いくつかの変数名をランダムな名前に置き換えました。
Private Sub FillTable(ByVal vProjetID As String)
Dim sqlquery As String = "SELECT SUM(EFFORT_RESRC.NB_JP_PLANF) as Planifie, SUM(EFFORT_RESRC.NB_JP_DDC) as DDC, SUM(EFFORT_RESRC.NB_JP_REEL) as Reel, SUM(EFFORT_RESRC.NB_JP_RESTN) as RAF, " & _
"SUM(EFFORT_RESRC.NB_JP_REVS) as Revise, SUM(EFFORT_RESRC.NB_JP_PROJT) as Projete, SUM(EFFORT_RESRC.ECART_REVS_PROJT) as Ecart,RESRC.ID_VP , VICE_PRESD.DE_VP, TA_COMPS.TAUX " & _
"FROM EFFORT_RESRC INNER JOIN " & _
"TA_COMPS ON EFFORT_RESRC.COMPOSANTEID = TA_COMPS.COMPOSANTEID INNER JOIN " & _
"RESRC ON EFFORT_RESRC.NO_EMPLY = RESRC.NO_EMPLY INNER JOIN " & _
"VICE_PRESD ON RESRC.ID_VP = VICE_PRESD.ID_VP " & _
"WHERE EFFORT_RESRC.PROJETID = '" & vProjetID & "' AND EFFORT_RESRC.ANNEE = '" & dd_ressourceprojet_annee.SelectedValue & "' AND TA_COMPS.ANNEE = '" & dd_ressourceprojet_annee.SelectedValue & "' " & _
"GROUP BY RESRC.ID_VP, VICE_PRESD.DE_VP, TA_COMPS.TAUX " & _
"ORDER BY VICE_PRESD.DE_VP"
Dim dtRessource As New DataTable
Master.GetDataTable(dtRessource, sqlquery)
While (tblBudgetRessourceVP.Rows.Count > 1)
tblBudgetRessourceVP.Rows.RemoveAt(1)
End While
Dim tr As HtmlTableRow
Dim td As HtmlTableCell
For Each ressource As DataRow In dtRessource.Rows
If ressource("DE_VP") <> curStrVP And curStrVP <> String.Empty Then
tr = New HtmlTableRow
td = New HtmlTableCell
td.InnerHtml = curStrVP
tr.Cells.Add(td)
td = New HtmlTableCell
td.Attributes.Add("class", "budget")
If rdiolist.SelectedIndex = 0 Then // Check the selector, if $ or Days display
td.InnerHtml = Format(curPlan, "### ### ### ### ### ##0.00$")
Else
td.InnerHtml = Format(curPlan, "####")
End If
totPlan += curPlan
tr.Cells.Add(td) // Add the cell to the table.
td = New HtmlTableCell
td.Attributes.Add("class", "budget")
If rdiolist.SelectedIndex = 0 Then // Check if JP or $ is selected for display format.
td.InnerHtml = Format(curDDC, "### ### ### ### ### ##0.00$")
Else
td.InnerHtml = Format(curDDC, "####")
End if
totDDC += curDDC
tr.Cells.Add(td)
td = New HtmlTableCell
td.Attributes.Add("class", "budget")
If rdiolist.SelectedIndex = 0 Then // Check if JP or $ is selected for display format.
td.InnerHtml = Format(curRevise, "### ### ### ### ### ##0.00$")
Else
td.InnerHtml = Format(curRevise, "####")
End If
totRevise += curRevise
tr.Cells.Add(td)
みんな、ありがとう。