Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult Admin(uint id, FormCollection collection) {
- var username = collection.Get("username");
- var password = collection.Get("password");
- Helper.CreateUser(username,password);
- return View("AdministerUsers");
- }
- <% using (Html.BeginForm()){ %>
- <fieldset>
- <legend>Fields</legend>
- <label for="username">username</label>
- <%= Html.TextBox("username") %>
- <label for="password">password:</label>
- <%= Html.TextBox("password") %>
- </fieldset>
- <input type="submit" value="Add User" name="submitUser" />
- <% } %>
- routes.MapRoute(
- "Admin",
- "Admin/{id}",
- new { controller = "Administration", action = "Admin"}
- );
- public class ViewModel
- {
- public string Username {get; set;}
- public string Password {get; set;}
- }
- <%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<ViewModel>" %> //the ViewModel will need to have it's fully qualified name here
- <% using (Html.BeginForm()){ %>
- <%= Html.LabelFor(m => m.Username) %>
- <%= Html.TextBoxFor(m => m.Username) %>
- <%= Html.Label(m => m.Password) %>
- <%= Html.TextBoxFor(m => m.Password) %>
- <input type="submit" value="Add User" name="submitUser" />
- <% } %>
- [HttpPost]
- public ActionResult Admin(ViewModel model)
- {
- var username = model.Username;
- var password = model.Password;
- Helper.CreateUser(username,password);
- return View("AdministerUsers");
- }
- public ActionResult Admin(uint id, string username, string password)
- {
- // .. Do your stuff
- }
Add Comment
Please, Sign In to add comment