Skip to content

Instantly share code, notes, and snippets.

@nootn
Created April 23, 2012 10:10
Show Gist options
  • Save nootn/2470080 to your computer and use it in GitHub Desktop.
Save nootn/2470080 to your computer and use it in GitHub Desktop.
MVC Mega Forms quick start guide - ChangeVisually
//Supply defaults for MegaForms
var MegaFormsChangeVisuallyJQueryParentContainerSelector = '.container'; //sets the class of a component that wraps a whole form control (I.e. label + input + validation message)
var MegaFormsChangeVisuallyJQueryHideEffect = 'fast'; //sets the jQuery effect to use when hiding a field
var MegaFormsChangeVisuallyJQueryShowEffect = 'slow'; //set the jQuery effect to use when showing a field
PM> Install-Package MvcMegaForms
//This will show as a checkbox on the screen - checking it will show "TheNextHidingField"
public bool ShowTheNextHidingField { get; set; }
[ChangeVisually(ChangeVisuallyAttribute.ChangeTo.Hidden, "ShowTheNextHidingField", ChangeVisuallyAttribute.DisplayChangeIf.Equals, false, false)]
public string TheNextHidingField { get; set; }
//This will show as a checkbox on the screen - checking it will enable "TheNextDisabledField"
public bool EnableTheNextDisabledField { get; set; }
[ChangeVisually(ChangeVisuallyAttribute.ChangeTo.Disabled, "EnableTheNextDisabledField", ChangeVisuallyAttribute.DisplayChangeIf.Equals, false, false)]
public string TheNextDisabledField { get; set; }
<fieldset>
<legend>Please fill in the form</legend>
<ol>
<li class="container">
@Html.LabelFor(m => m.ShowTheNextHidingField)
@Html.CheckBoxFor(m => m.ShowTheNextHidingField)
@Html.ValidationMessageFor(m => m.ShowTheNextHidingField)
</li>
<li class="container">
@Html.LabelFor(m => m.TheNextHidingField)
@Html.TextBoxFor(m => m.TheNextHidingField)
@Html.ValidationMessageFor(m => m.TheNextHidingField)
</li>
<li class="container">
@Html.LabelFor(m => m.EnableTheNextDisabledField)
@Html.CheckBoxFor(m => m.EnableTheNextDisabledField)
@Html.ValidationMessageFor(m => m.EnableTheNextDisabledField)
</li>
<li class="container">
@Html.LabelFor(m => m.TheNextDisabledField)
@Html.TextBoxFor(m => m.TheNextDisabledField)
@Html.ValidationMessageFor(m => m.TheNextDisabledField)
</li>
</ol>
<input type="submit" value="submit" />
</fieldset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment