i have a checkbox that are checked based on the value from my xml but how do i then get the value from the view to the controller
<input @(Convert.ToBoolean(setting.GSuccess)==true ? "checked='checked'" : string.Empty) type="checkbox" /></td>
controller
[AcceptVerbs(HttpVerbs.Post), ActionName("Settings")]
public ActionResult Save(SettingsModel setting)
{
Boolean gSuccess = setting.GSuccess;
List<SettingsModel> settings = new List<SettingsModel>();
//Load the XML file in XmlDocument.
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/XML/Settings.xml"));
//Loop through the selected Nodes.
foreach (XmlNode node in doc.SelectNodes("/Settings/UserSettings"))
{
//Fetch the Node values and assign it to Model.
settings.Add(new SettingsModel
{
GSuccess = Boolean.Parse(node["GSuccess"].InnerText)
});
doc.Save(Server.MapPath("~/XML/Settings.xml"));
}
return RedirectToAction("Settings", "Home");
;
}
}
}
Aucun commentaire:
Enregistrer un commentaire