here is how to add javascript onchange function to DropDownListFor MVC helper:
@Html.DropDownListFor(m => m.SettingValue, new SelectList(Model.globalTypes, "TypeCode", "TypeName"), new { onchange = "SettingChanged()" })
@Html.DropDownListFor(m => m.SettingValue, new SelectList(Model.globalTypes, "TypeCode", "TypeName"), new { onchange = "SettingChanged()" })
// get all form values into json
var s2=$('form').values();
// restore all forms values back
$('form').values(s2);
/* function for form saving restoring code */
$.fn.values = function (data) {
var els = $(this).find(':input').get();
if (typeof data != 'object') {
// return all data
data = {};
$.each(els, function () {
if (this.name && !this.disabled && this.type != "hidden") {
if (this.type == 'checkbox') {
data[this.name] = $(this).is(":checked");
} else if (this.type == 'radio') {
if ($(this).is(":checked")) {
data[this.name] = $(this).val();
}
} else {
data[this.name] = $(this).val();
}
}
});
return data;
} else {
$.each(els, function () {
if (this.name && data[this.name] != null) {
//console.log(">" + this.name + " " + data[this.name]);
if (this.type == 'checkbox') {
$(this).attr("checked", data[this.name]); //(data[this.name] == $(this).val())
//console.log("checkbox");
} else if (this.type == 'radio') {
$(this).attr("checked", data[this.name] == $(this).val());
} else {
$(this).val(data[this.name]);
}
}
});
return $(this);
}
};
Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...