私は周りを見回しましたが、解決策が見つからないため、ここにいます。私が読んだことから、RegisterClientScriptまたはRegisterClientScriptBlockを使用してasp.net Webフォームでこれを行うことができました。これはどの MVC3 ドキュメントにもありません。MVC 3 View に次の機能があります。
MyTest ビュー:
<div data-role="content">
<div id="mappingTable"></div>
</div>
</section>
@section Scripts {
<script type="text/javascript">
$("#jqm-home").live('pageinit', function () {
addTableRow(' adding data to table <br/>');
});
//I want to the able to call the function from the controller.
function addTableRow(msg) {
$('#mappingTable').append(msg);
};
</script>
}
私のコントローラーには次のものがあります。
public class MyTestController : Controller
{
#region Class Constractor
public MyTestController()
{
Common.ControllerResourceEvent += new System.EventHandler<ResourceEventArgs>(Common_ResourceEvent);
}
private void Common_ResourceEvent(object sender, ResourceEventArgs e)
{
//I want to call the function addTableRow and pass ResourceEventArgs
}
#endregion Class Constractor
public ActionResult Index()
{
return View();
}
}