ユーザーが検索を実行できる部分ビューがあり、検索結果が選択ボックスに表示されます。私のメインビューには、選択ボタンが押された後に検索結果を表示するセクションがあります。現在、選択ボタンをクリックすると、正しい情報がメイン ビューの正しいモデルに読み込まれますが、メイン ビューは変更されません。更新をクリックすると、ページが正しく更新されます。プラグイン ビューでボタンがクリックされたときにページを自動的に更新するにはどうすればよいですか?
Index.vbhtml
メイン アプリのメイン ビュー ( ) のセクション:
@Section CUInfo
Credit Union Name: @Model.CUInfo.CUName
end section
プラグインのコントローラー メソッドは次のとおりです。
Function ChangeCUInfo(strCUName As String) As ActionResult
m_hostApp.CUInfo.CUName = strCUName
m_hostApp.blnPluginRefreshButtonPressed = True
Return View("Index", m_hostApp)
End Function
hostApp オブジェクトにブール値を設定しようとしましたが、メインのカミソリ ビューで true の場合はこの関数を呼び出します。
@code
If Model.blnPluginRefreshButtonPressed = True Then
@<script type="text/javascript">
$(function () {
window.location.reload();
});
</script>
End If
Model.blnPluginRefreshButtonPressed = False
End Code
編集:
選択ボタンがクリックされたときに呼び出される JS 関数:
function loadCU(CUInfo) {
strCU = CUInfo.split('|');
strCUName = strCU[0];
$.ajax({
type: "POST",
url: "/CUContractNumberPlugin/ChangeCUInfo",
data: { "strCUName": strCUName }
});
}
プラグイン ビューで使用されるフォーム:
@Using (Html.BeginForm("ChangeCUInfo", "CUContractNumberPlugin"))
@<div id="LogoSigSearch" style="height:300px;width:500px;position:relative;">
<span style="display:inline-block;height:20px;width:166px;position:absolute;top:35px;left:5px;">Credit Union Name</span>
<br />
@Html.TextBox("strCUName")
<input type="submit" name="LogoSigSearch$ctl02" value="Search" id="LogoSigSearch_ctl02" tabindex="3" style="width:60px;position:absolute;top:5px;left:352px;" />
<input name="LogoSigSearch$ctl05" type="button" onclick="javascript:clearSearch()" value="Clear" style="position:absolute;top:35px;left:352px;width:60px;" />
<select size="4" name="LogoSigSearch$ctl06" id="LogoSigSearch_ctl06" tabindex="5" style="height:230px;width:342px;position:absolute;top:65px;left:5px;"></select>
<input type="button" name="SelectCU" value="Select" onclick="javascript:loadCU(LogoSigSearch_ctl06.options[LogoSigSearch_ctl06.selectedIndex].value)" tabindex="4" style="width:60px;position:absolute;top:65px;left:352px;" />
</div>
End Using