Using a strongly typed partial view as Macro , so that i can use it in multiple pages
I have a situation where i need to create a form which takes user input from text boxes and save it to the database (this form will be used at several places in the website) , so i have created a partial view and then a macro with that partial view , now when i try to put that macro in my grid it says failed to load partial view . what am i lacking into ?
here is my Model class
public class TestViewModel { [Required(ErrorMessage="*")] [StringLength(100, ErrorMessage = "Length of last name is not valid")] public string LastName { get; set; }
[Required] [Display(Name = "Email Address")] [RegularExpression(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$", ErrorMessage = "Enter a valid email address")] [StringLength(100, ErrorMessage = "Length of Email Address is not valid")] public string Email { get; set; } }
Using a strongly typed partial view as Macro , so that i can use it in multiple pages
I have a situation where i need to create a form which takes user input from text boxes and save it to the database (this form will be used at several places in the website) , so i have created a partial view and then a macro with that partial view , now when i try to put that macro in my grid it says failed to load partial view . what am i lacking into ?
here is my Model class
public class TestViewModel
{
[Required(ErrorMessage="*")]
[StringLength(100, ErrorMessage = "Length of last name is not valid")]
public string LastName { get; set; }
[Required]
[Display(Name = "Email Address")]
[RegularExpression(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$", ErrorMessage = "Enter a valid email address")]
[StringLength(100, ErrorMessage = "Length of Email Address is not valid")]
public string Email { get; set; }
}
and here is my partial view
@using GettingStarted.BLL.ViewModels.TestViewModel
@{
Layout=null;
}
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new { @class = "form-horizontal" }))
{
@Html.TextBoxFor(x => x.LastName, new { @class = "form-control", @placeholder = "Last Name" })
@Html.TextBoxFor(x => x.Email, new { @class = "form-control", @placeholder = "Email" })
@Html.ValidationMessageFor(x => x.Email)
}
Hi Yogesh,
Is your macro working at another places in the project ?
Hey Alex,
NO , actully making it reuseable is a plan for future.
Thanks
can anyone help me to create a macro by which i can take input from the user and save it to the database?
is working on a reply...