asp.net-mvc 如何在asp.Net MVC Razor中触发Check Box的Click事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10420159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 01:55:10  来源:igfitidea点击:

How to fire Click event of Check Box in asp.Net MVC Razor

asp.net-mvccheckbox

提问by Umesh K.

I have a check box for "IsQuantityAvailable" for selecting if a seller have availability of commodities and on CLICK of this chkBox I have to show a TextBoxfor entering quantity of commodity.Please suggest a solution using MVC Razor...Thanks!!

我有一个“IsQuantityAvailable”复选框,用于选择卖家是否有可用商品,点击此 chkBox 时,我必须显示一个用于输入商品数量的文本框。请建议使用 MVC Razor 的解决方案...谢谢!

回答by amarnath chatterjee

As mario suggested, the solution hasn't much to do with razor, however this might help. Create the checkbox using Html.Checkbox or Html.CheckboxFor if u have strict model binding. Add onclick eventhandler to checkbox while adding

正如马里奥所建议的那样,解决方案与剃须刀没有太大关系,但这可能会有所帮助。如果您有严格的模型绑定,请使用 Html.Checkbox 或 Html.CheckboxFor 创建复选框。添加时将 onclick 事件处理程序添加到复选框

@Html.Checkbox( "somename", new { @onclick="function-to-open-dialog()"})

Implementation of "function-to-open-dialog" will depend upon what you are using at client site. If its jquery then it could be simple call like $("#DialogId").dialog("open")

“功能到打开的对话框”的实现将取决于您在客户端站点使用的内容。如果它的 jquery 那么它可能是简单的调用,如 $("#DialogId").dialog("open")