razor

jQuery/Ajax simple form post in webmatrix

≯℡__Kan透↙ 提交于 2020-01-16 19:37:27
问题 Can someone please tell me the code I need, so that this form updates the database without needing a refresh? @{ Layout = "~/_template1.cshtml"; var db = Database.Open("stayinflorida"); var CurrentUser = WebSecurity.CurrentUserId; var userdetails = ("SELECT * from UserProfile WHERE UserId='8'"); var quserdetails = db.QuerySingle(userdetails, CurrentUser); if (IsPost){ var updateuserdetails = "UPDATE UserProfile SET FirstName = @0, LastName = @1 WHERE UserID='8'"; db.Execute(updateuserdetails,

jQuery/Ajax simple form post in webmatrix

南笙酒味 提交于 2020-01-16 19:36:49
问题 Can someone please tell me the code I need, so that this form updates the database without needing a refresh? @{ Layout = "~/_template1.cshtml"; var db = Database.Open("stayinflorida"); var CurrentUser = WebSecurity.CurrentUserId; var userdetails = ("SELECT * from UserProfile WHERE UserId='8'"); var quserdetails = db.QuerySingle(userdetails, CurrentUser); if (IsPost){ var updateuserdetails = "UPDATE UserProfile SET FirstName = @0, LastName = @1 WHERE UserID='8'"; db.Execute(updateuserdetails,

Add related entities with ASP.NET MVC and Razor?

不羁的心 提交于 2020-01-16 18:33:15
问题 I have a Person class that has a navigation property ICollection<Address> Addresses . The Address entity has a property City . I want to give the user an option to create/update a Person along with its addresses, including adding and removing ones. So for displaying the addresses I simply call @Html.EditorFor(m => m.Addresses) , and the razor engine takes care of the collection using my custom template that resides in the EditorTemplates folder, generating foreach field a matching signature

How to define conditional model binding in ASP.NET Core Razor Pages?

淺唱寂寞╮ 提交于 2020-01-16 08:36:32
问题 I'm trying to make a simple login form in ASP.NET Core Razor Pages, which has an email address field, a password field, a login button and a forgot-password button. I want to utilize the inbuilt client-side and server-side validation on the text fields, such that the email field is required for both button submissions, but the password field is only required for login button submission. Decorating the model properties with a [Required] attribute makes them mandatory for all form post handlers

update .html with @HTML helper DropDownList

醉酒当歌 提交于 2020-01-16 05:24:28
问题 MVC4, C#, jQuery, Razor view (.cshtml) I'm trying to update the .html() of a node with a @HTML.DropDownList: <script type="text/javascript"> $('#CmpMASttF').html('@Html.DropDownList("CmpAdrsSt.State", (IEnumerable<SelectListItem>)ViewBag._State) @Html.ValidationMessageFor(m => m.CmpAdrsSt.State) '); </script> This works fine for a @HTML.EditorFor: $('#CmpMASttF').html('@Html.EditorFor(m => m.CmpAdrsSt.State) @Html.ValidationMessageFor(m => m.CmpAdrsSt.State) '); This is the node being updated

Search refinement for WebMatrix site

核能气质少年 提交于 2020-01-16 03:18:46
问题 I've been asking a few questions on this site, and have answers to lots of little bits, but I am now trying to piece the whole thing together. I have a page where it shows all the properties I have in my database. I need to find a way to refine those results though, so for example, to only show properties that have 4 bedrooms etc. The problem is, I don't know how many variables I might have in the search term yet. So here's an example. a user may want to see ALL properties that just have 4

ASP.NET MVC ActionLink vs RedirectToAction for images in areas

别来无恙 提交于 2020-01-16 01:19:08
问题 I have an issue with an image that is a little hard to explain so hopefully this will make sense. I am using ASP.NET MVC 4 Razor. I have one area setup and I am using a layout page that in the root. Everything is working fine except one small issue. When I use an ActionLink in an area, my page renders just fine including the layout page except for the image on the page. If I use RedirectToAction in my controller, everything renders fine including the image. I can see the location of the image

MVC 5.2.2.0: @Scripts.Render(…) not recognized

与世无争的帅哥 提交于 2020-01-16 00:55:10
问题 I've recently upgraded my Visual Studio to update 4 (2013) and apparently my MVC version has been upgraded as well. The problem is that, I can no longer use the @Scripts.Render because it does not recognize the Scrripts type and it says it does not exist. I know that it is from System.Web.Optimization but the Optimization namespace is also missing. Why I'm using @Scripts is because of client-side validation and before this upgrade I had no issue with that. So is that a bug or has Microsoft

MVC3 partial view postback not work?

穿精又带淫゛_ 提交于 2020-01-15 18:52:23
问题 I have LogOn partial view in the AccountController : public ActionResult LogOn() { return PartialView(); } // // POST: /Account/LogOn [HttpPost] public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (ModelState.IsValid) { if (MembershipService.ValidateUser(model.UserName, model.Password)) { FormsService.SignIn(model.UserName, model.RememberMe); } else { ModelState.AddModelError("", Resources.Account.Account.LoginFailureText); } } } return PartialView

MVC3 partial view postback not work?

99封情书 提交于 2020-01-15 18:51:51
问题 I have LogOn partial view in the AccountController : public ActionResult LogOn() { return PartialView(); } // // POST: /Account/LogOn [HttpPost] public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (ModelState.IsValid) { if (MembershipService.ValidateUser(model.UserName, model.Password)) { FormsService.SignIn(model.UserName, model.RememberMe); } else { ModelState.AddModelError("", Resources.Account.Account.LoginFailureText); } } } return PartialView