i have created user login form by using custom table(own table) in umbraco 7.2 .user registration form created by using petapoco method.
model code below
[TableName("UserLogin")]
[PrimaryKey("UserId", autoIncrement = true)]
[ExplicitColumns]
public class User
{
[Column]
public string UserId { get; set;}
[Column]
[Required(ErrorMessage = "Please provide Name", AllowEmptyStrings = false)]
public string Name { get; set; }
[Column]
[Required(ErrorMessage = "Please provide Email",AllowEmptyStrings=false)]
[DataType(DataType.EmailAddress)]
[RegularExpression("^([a-zA-Z0-9_\\-\\.]+)@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$", ErrorMessage = "Email is not a valid e-mail address.")]
public string Email { get; set; }
[Column]
[Required(ErrorMessage = "Please provide Adress", AllowEmptyStrings = false)]
public string Address { get; set; }
[Column]
[RegularExpression(@"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$", ErrorMessage = "Entered mobile format is not valid.")]
public string Mobile { get; set; }
[Column]
[Required(ErrorMessage = "Please provide Password", AllowEmptyStrings = false)]
[DataType(DataType.Password)]
[StringLength(255, MinimumLength =6, ErrorMessage = "please enter minimum 6 character")]
public string Password { get; set; }
[Required(ErrorMessage = "Please provide Confirm Password", AllowEmptyStrings = false)]
[Compare("Password", ErrorMessage = "Confirm password dose not match.")]
[DataType(DataType.Password)]
[StringLength(255, MinimumLength = 6, ErrorMessage = "please enter minimum 6 character")]
public string UserConfirmPassWord { get; set; }
}
controller(User controller) code is below
public ActionResult AddUser(User _user)
{
//Add new user
if (!ModelState.IsValid)
{
ViewBag.MessageError = "Not Successfully Registration";
return CurrentUmbracoPage();
}
var db = ApplicationContext.Current.DatabaseContext.Database;
_user.Password = Encrypt(_user.Password);//Encrypt the password
_user.IsActive = false;
db.Insert(_user);
ViewBag.MessageSuccess = "Successfully Registration Done";
return Redirect("/home/login/");
// return CurrentUmbracoPage();
}
but i want to edit table with id..i need controller and view code..can u help me?
//Get the Umbraco db
var db = ApplicationContext.DatabaseContext.Database;
//Add the object to the DB
db.Insert(blogPostToAdd);
//Update the object in the DB
db.Update(blogPostToAdd);
//Delete the object from the DB
db.Delete(blogPostToAdd);
[HttpGet]
public ActionResult EditUser()
{
var db = ApplicationContext.Current.DatabaseContext.Database;
var user = db.Fetch<User>("Select Name,Email,Address,Mobile from UserLogin where UserId=@0", 1101);
return PartialView("EditUser", user);
}
*EditUser is my partial page
Edituser view page like this...how to render the selected value in partial view page?
edit table by using umbraco mvc ?
i have created user login form by using custom table(own table) in umbraco 7.2 .user registration form created by using petapoco method. model code below
but i want to edit table with id..i need controller and view code..can u help me?
Hi Sarathy,
Great article with example how to insert/update/delete rows from custom tables in Umbraco. http://creativewebspecialist.co.uk/2013/07/16/umbraco-petapoco-to-store-blog-comments/
Thanks, Alex
Thanks alex for reply...how to pass id from controller to partial view page for edit operation when i click the edit button?
Try to use new property with id, and store this value in the hidden field.
public int Id { get; set;}
edituser controller code
*EditUser is my partial page
Edituser view page like this...how to render the selected value in partial view page?
Hi Sarathy,
It's common task in MVC,
Example:
Thanks, Alex
is working on a reply...