OnClick event on button in MvcContrib Grid column

2019-09-16 13:42发布

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?

0条回答
登录 后发表回答