简体   繁体   中英

How do I add checkbox in 2sxc application razor view?

Multiple attempts to use few methods with different combinations of parameters don't work for me so far.

  • @Html.CheckBox() causes strange behaviour: I give it 2 parameters ( @Html.CheckBox(Html, "asdf") ) - it says that best extension method overload 'DotNetNuke.Web.Mvc.Helpers.HtmlInputExtensions.CheckBox has 3 parameters ( 'DotNetNuke.Web.Mvc.Helpers.HtmlInputExtensions.CheckBox(DotNetNuke.Web.Mvc.Helpers.DnnHtmlHelper, string, bool)' ). I give it 3 parameters ( @Html.CheckBox(Html, "asdf", true) ), it says then that best overload has 4 parameters. What is going on???
  • @Html.CheckBoxFor() => CS1501: No overload for method 'CheckBoxFor' takes 0 arguments
  • @Html.CheckBoxFor("asdf") => CS1061: 'ToSic.Sxc.Dnn.Web.IHtmlHelper' does not contain a definition for 'CheckBoxFor' and no extension method 'CheckBoxFor' accepting a first argument of type 'ToSic.Sxc.Dnn.Web.IHtmlHelper' could be found (are you missing a using directive or an assembly reference?) . What??? Actually I've just given you a string parameter, not IHtmlHelper .
  • @System.Web.WebPages.Html.CheckBox("test") causes error CS0234: The type or namespace name 'CheckBox' does not exist in the namespace 'System.Web.WebPages.Html' (are you missing an assembly reference?)

How do I add checkbox here and paste its value in button url?

I must say I never used this @Html.Checkbox but it's probably not supported on the built-in @Html object. So anything with @System.Web.Webpages... etc. is probably the right way, but you must know that Razor in DNN uses an older version of MVC, probably v3 or something.

That could be part of the issue.

Either way I simply suggest to quickly write the HTML to get this working :).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM