OnClick event on button in MvcContrib Grid column not working

爱⌒轻易说出口 提交于 2019-12-11 20:46:22

问题


I am new to mvc.I am using MvcContrib Html.Grid in my MVC 2 project.I have an existing Html.Grid where I have to added a new column with a button in it. The button will be enabled/disabled bsed on the "status" column in the grid. I managed to get the button in the column and enable/disable it based on the "status" column. Here's the code:

column.For(c => c.Status == "Complete" ? "<input type=\"button\" value=\"PDF\" onClick=\"\" >" : "<input type=\"button\" value=\"PDF\" onClick=\"\" disabled='disabled'>").Named("Generate Report").Encode(false);

How can I call an Action in a Controller on this button's "onclick" event?

EDIT: I tried this:

column.For(c => c.EPCRStatus == "Complete" ? "<input type=\"button\" value=\"PDF\" onClick=\"javascript:window.open('<%= Url.Action(\"GenerateCaseSheetReport\",\"CareRecord\",new { id = Model.CareRecord.CaseNumber })%>');\" >" : "<input type=\"button\" value=\"PDF\" disabled='disabled'>").Named("Generate Report").Encode(false);

but it says "Newline in constant". How do I get rid of this error?

来源:https://stackoverflow.com/questions/18478797/onclick-event-on-button-in-mvccontrib-grid-column-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!