问题
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