Search Results

Search found 165 results on 7 pages for 'httpverbs'.

Page 3/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Model Not Valid Even With No [Required] Attribute

    - by griegs
    I have a model which is validating as False even though I have no validation rules attached to it what so ever. So this is my model; public class QuickQuote { public Enumerations.AUSTRALIA_STATES state { get; set; } public Enumerations.FAMILY_TYPE familyType { get; set; } public Enumerations.CoverLevel hospitalCover { get; set; } public Enumerations.CoverLevel extrasCover { get; set; } public Enumerations.YesNo pregnancy { get; set; } } And in my controller I have; [AcceptVerbs(HttpVerbs.Post)] public ActionResult Index(IndexFormViewModel fvm) { if (!ModelState.IsValid) return View(fvm); The problem is that unless I put a value into each field it's validating as false even though it shouldn't care. Can anyone see what the problem is here?

    Read the article

  • ASP.NET MVC ajax - data transfer

    - by Grienders
    How can I get result from action? I need to show the commentID on the page (aspx) after successes comment insert. controller [AcceptVerbs(HttpVerbs.Post )] public ActionResult ShowArticleByAjax(Guid id, string commentBody) { Guid commentID = Comment.InsertComment(id, commentBody); //How can I tranfer commentID to the aspx page ??? return PartialView("CommentDetails",Article.GetArticleByID(id)); } ascx <%using (Ajax.BeginForm("ShowArticleByAjax", new { id = Model.ID }, new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "divCommentDetails", OnSuccess = "successAddComment", OnFailure = "failureAddComment", OnBegin = "beginAddComment" })) { %> <p> <%=Html.TextArea("commentBody", new { cols = "100%", rows = "10" })%> </p> <p> <input name="submit" type="image" src="../../Content/Images/Design/button_s.gif" id="submit" /> </p> <%} %> aspx doesn't matter

    Read the article

  • Session state in asp.net mvc

    - by tiff
    I would like to know how to use session state in a simple log in log out in asp.net mvc.. I have a code here in my controller that I've retrieved from my mysql database for my session log in..but I don't really know how to manipulate it.. <AcceptVerbs(HttpVerbs.Post)> _ Function Index(ByVal username As String, ByVal password As String, ByVal department As String) As ActionResult Dim user As DataTable user = Account.userSelect(username:=username, password:=password, department:=department) If user.Rows.Count = 0 Then Return RedirectToAction("Index", "Home") Else Session("username") = user.Rows(0).Item("username") Session("department") = user.Rows(0).Item("department") Return RedirectToAction("News", "Administration") End If End Function Thank you!

    Read the article

  • asp.net mvc form add comment

    - by Pinu
    I have a page where a product appears on the right side and the user can add comment so i have a user control which gets all the comments and a small text area where user can add new comment for that product. the link of the page is like http://localhost/Product/TestComment/1 Where 1 indicates the id of the product and I have been hard coding my AddNote function below and fourth argument you see has been hard coded, but i need to pass that as the id of the product. How do i do this AddNote(HttpContext.User.Identity.ToString(), txtComment, 1, DateTime.Now, true); [AcceptVerbs(HttpVerbs.Post)] public ActionResult AddComment(string txtComment) { bool rst = _NotesService.AddNote(HttpContext.User.Identity.ToString(), txtComment, 1, DateTime.Now, true); return RedirectToAction("TestComment"); }

    Read the article

  • ASP.NET MVC & Detached Entity won't save

    - by Justin
    Hey all, I have an ASP.NET MVC POST action for saving an entity on submit of a form. It works fine for insert but doesn't work for update, the database doesn't get called, so it's clearly not tracking the changes, as it's "detached". I'm using Entity Framework w/.NET 4: //POST: /Developers/Save/ [AcceptVerbs(HttpVerbs.Post)] public ActionResult Save(Developer developer) { developer.UpdateDate = DateTime.Now; if (developer.DeveloperID == 0) {//inserting new developer. DataContext.DeveloperData.Insert(developer); } //save changes - TODO: doesn't update... DataContext.SaveChanges(); //redirect to developer list. return RedirectToAction("Index"); } Any ideas would be greatly appreciated, thanks, Justin

    Read the article

  • How do the httppost, httpput etc attributes in ASP.NET MVC 2 work?

    - by Tomas Lycken
    In ASP.NET MVC 2, a couple of new action filter attributes were introduced, as "shorthand" for attributes in ASP.NET MVC 1; for example, applying the HttpPostAttribute does the same thing as applying [AcceptVerbs(HttpVerbs.Post)] to an action method. In addition, with the more verbose syntax, it is possible to combine different methods, in order to allow for example both Post and Delete. Now I'm wondering: how do the new attributes work? If I apply both [HttpPost] and [HttpDelete], will ASP.NET MVC 2 allow both or require both (thus allowing nothing)?

    Read the article

  • jQuery Form, ASP.NET MVC JSon Result

    - by Stacey
    I'm trying to return a json result from a jQuery Form instance - but it keeps prompting me to download a file instead of displaying it in the window like it is supposed to... $("#ajaxImageForm").ajaxForm({ iframe: true, type: "GET", dataType: "json", beforeSubmit: function() { $("#ajaxImageForm").block({ message: '<img src="/content/images/loader.gif" /> Uploading . . .' }); }, success: function(result) { $("#ajaxImageForm").unblock(); $.growlUI(null, result.message); } }); [AcceptVerbs(HttpVerbs.Post)] public JsonResult Edit(FormCollection collection) { // return Json to the jQuery Form Result return new JsonResult { Data = new { message = string.Format("edited successfully.") } }; }

    Read the article

  • fill data in dropdown box as per previous dropdown box data selected in aspnet mvc 1

    - by FosterZ
    hi, i'm buildin' an employee registration form in aspnet mvc, i have fields like "School" list in 1 dropdown box and "Department" list another, problem is i want to show Department list on change of School list, i have done followin' code: public ActionResult EmployeeCreate() { var getSchool = SchoolRepository.GetAllSchoolsInArray();//this gets school_id as value and school_name as text for dropdown box ViewData["SchoolsList"] = getSchool; return View(); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult EmployeeCreate() { _employeeRepository.CreateEmployee(employeeToCreate); _employeeRepository.SaveToDb(); } Here is the View Html.DropDownList("SchoolLists") Html.DropDownList("DepartmentLists") now, how do i get the departments of selected school in dropdown boxes

    Read the article

  • how do i call an overloaded action in .net mvc?

    - by Jeff Martin
    I have an overloaded action in my Controller: public ActionResult AssignList(int id) { ... } [AcceptVerbs((HttpVerbs.Get))] public ActionResult AssignList(int id, bool altList) { ... } I'd like to use the same partial view for both lists but it will potentially have a differently filtered list of Images. I am trying to call it from another view using RenderAction: <% Html.RenderAction("AssignList", "Image", new { id = Model.PotholeId, altList = true }); %> However I am getting the following error: The current request for action 'AssignList' on controller type 'ImageController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult AssignList(Int32) on type UsiWeb.Controllers.ImageController System.Web.Mvc.ActionResult AssignList(Int32, Boolean) on type UsiWeb.Controllers.ImageController How can I call the specific overload?

    Read the article

  • Caching view-port based Geo-queries

    - by friism
    I have a web app with a giant Google Map in it. As users pan and zoom around on the map, points are dynamically loaded through AJAX call which include the viewport bounds (NE and SW corner coordinates) and some other assorted parameters. How do I cache these request for points? The problem is that the parameters are highly variable and (worst) not discrete i.e. floats with a lots of decimal places. I'm using ASP.NET-MVC/C#/LINQ2SQL/SQL-Server but the problem is not tied to that platform. This is the signature of the the relevant method: [AcceptVerbs(HttpVerbs.Post)] public JsonResult Data(string date, string categories, string ne_lat, string ne_lng, string sw_lat, string sw_lng)

    Read the article

  • Returning a JSON view in combination with a boolean

    - by Rody van Sambeek
    What i would like to accomplish is that a partiel view contains a form. This form is posted using JQuery $.post. After a successfull post javascript picks up the result and uses JQuery's html() method to fill a container with the result. However now I don't want to return the Partial View, but a JSON object containing that partial view and some other object (Success - bool in this case). I tried it with the following code: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, Item item) { if (ModelState.IsValid) { try { // ... return Json(new { Success = true, PartialView = PartialView("Edit", item) }); } catch(Exception ex) { // ... } } return Json(new { Success = false, PartialView = PartialView("Edit", item) }); } However I don't get the HTML in this JSON object and can't use html() to show the result. I tried using this method to render the partial as Html and send that. However this fails on the RenderControl(tw) method with a: The method or operation is not implemented.

    Read the article

  • Controller getting NULL value?

    - by RSolberg
    I'm trying to make a call to a controller via jQuery $.post, but the parameter for my controller method keeps getting a NULL value despite it appearing to be setup similar to other controller methods. CONTROLLER [AcceptVerbs(HttpVerbs.Post)] public ActionResult SearchWeatherLocations(string searchFor) { //Do Some Magic } GLOBAL.ASAX routes.MapRoute("SearchWeatherLocations", "Home/SearchWeatherLocations/{searchFor}", new { controller = "Home", action = "SearchWeatherLocations" }); jQuery Call From View <script type="text/javascript" language="javascript"> $(document).ready(function () { GetWeatherLocations("seat"); }); function GetWeatherLocations(sSearchFor) { var divToBeWorkedOn = '#locations'; var webMethod = '<%= Url.Action("SearchWeatherLocations", "Home") %>/'; var url = webMethod + sSearchFor; $.post(url, function (data) { $('#locations').children().remove(); for (var count in data) { $('#locations').append("<li>" + data[count].LocationName + "&nbsp;(" + data[count].LocationCode + ")</li>"); } }); } </script>

    Read the article

  • JQuery $.post not working properly

    - by drupop
    Can't seem to find a fix for this issue I have the following code on the onclick event of an a html tag: AddVacationToCart( { ServiceSupplier:'Kiki', ProductId:'0;11968;0;0;187;1', Name:'Excelsior', NumberOfStars:'*****', TotalPrice:'1620.00', PriceLevelName:'Standard', Currency:'EUR', Status:'', StartDate:'2010-06-17', EndDate:'2010-06-24', NumberOfNights:'7', Rooms:[ { NumberOfAdults:'2', NumberOfChildren:'0', ChildrenAges:[] } ] },'0;11968;0;0;187;1');return false; I also have this code: function AddVacationToCart(vacation, id) { $.post("/ShoppingCart.mvc/AddVacation", vacation, function(data) { var div = $("div[id*=cartv" + id + "]"); var removeFromCartHtml = "Adaugat"; $(div).html(removeFromCartHtml); }, "json"); } This is the code in my ShoppingCartController AddVacation Action: [AcceptVerbs(HttpVerbs.Post)] public ActionResult AddVacation(Vacation test) { ... } The post works as in the (Vacation) test object gets filled with the corresponding properties like ServiceSupplier, ProductId, Name etc. Except the properties of my Rooms field do not get their corresponding values. Any ideeas?

    Read the article

  • ASP.NET MVC: Triggering an action before posting to Paypal payment gateway

    - by ajbeaven
    I'm in the middle of developing an e-commerce site that is using Paypal as it's payment gateway. All I want to do is run some code before the user heads off to Paypal to pay for their order, but I have no idea how to do it. The user should click a submit button, changes are made (in this case, the status of the order), and then the user is redirected to the payment gateway. Eg: [AcceptVerbs(HttpVerbs.Post)] public ActionResult GoToPaypal(FormCollection collection) { //change order status //send user to paypal where they pay for their order } So my question is how do you do application stuff and then redirect to paypal's payment gateway? Example HTML and C# would be lovely :)

    Read the article

  • Invoke an action that is using ASP.NET MVC [Authorize] from outside the application

    - by Nate Bross
    Is this possible? I'd like to expose a URL (action) such as http://mysever/myapp/UpdateHeartbeat/. In my MVC application it looks like [Authorize] [AcceptsVerbs(HttpVerbs.Post)] public ActionResult UpdateHeartbeat() { // update date in DB to DateTime.Now } Now, in my MVC application the user has logged in via FORMS authentication and they can execute that action to their hearts content. What I want to do, is hit that URL progromatically (as part of an API that I wouldl like to build) -- is there a way I can do that without removing the [Authorize] attribute and adding username/password as parameters to the POST?

    Read the article

  • Can Response.Redirect work in a private void MVC 2 Function?

    - by user54197
    I have a private void function set for some validation. Should my validation fail, I would like to redirect to another ActionResult and kill the process for the ActionResult that was being used. Response.Redirect("controllerName") does not help. Any ideas? [Accept(HttpVerbs.Post)] public ActionResult NerdDinner(string Name) { testName(Name); ... Return RedirectToAction("ActionResultAAA"); } private void testName(string name) { if(name == null) { //Response.Redirect("ActionResultBBB"); } }

    Read the article

  • How do i configure optional flags in MVC 1.0 routes

    - by Thomas Jespersen
    I want to configure a route with optional flags. E.g. I want to be able to call the products page and send optional filters (flags) for offers and in stock options. If the flags are NOT specified then all products should be returned. http://localhost/products http://localhost/products/onlyOnOffer http://localhost/products/onlyInStock http://localhost/products/onlyInStock/onlyOnOffer [AcceptVerbs(HttpVerbs.Get)] public ActionResult GetProducts(bool onlyInStock, bool onlyOnOffer) { //... } How would I configure the route? Is it even possible in MVC 1.0? What about MVC 2.0.

    Read the article

  • ASP .net Dropdown list not saving the selected value to database

    - by user326010
    Hi In the following code i want to save the value selected by user from drop downlist into database. but whatever value is selected by user, first value of dropdown lsit is saved to database View <% =Html.DropDownList("lstUsertype", (SelectList)ViewData["UserTypeID"])%> Controller public ActionResult CreateUser() { UmUser _UmUser = new UmUser(); UMRepository _UMRepository = new UMRepository(); EvoLetDataContext db = new EvoLetDataContext(); ViewData["UserTypeID"] = new SelectList(_UMRepository.FillUserTypes(), "UserTypeID", "UserType",2); return View(_UmUser); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult CreateUser(UmUser _umUser) { //try //{ if (ModelState.IsValid) { //try //{ UserRepository _UserRepository = new UserRepository(); _UserRepository.Add(_umUser); _UserRepository.Save(); return RedirectToAction("Details", new { id = _umUser.UserID }); /*} catch { ModelState.AddModelErrors(_umUser.GetRuleViolations()); }*/ } return View(); //} /*catch { return View(); }*/ }

    Read the article

  • keep viewdata on RedirectToAction

    - by Thomas Stock
    [AcceptVerbs(HttpVerbs.Post)] public ActionResult CreateUser([Bind(Exclude = "Id")] User user) { ... db.SubmitChanges(); ViewData["info"] = "The account has been created."; return RedirectToAction("Index", "Admin"); } This doesnt keep the "info" text in the viewdata after the redirectToAction. How would I get around this issue in the most elegant way? My current idea is to put the stuff from the Index controlleraction in a [NonAction] and call that method from both the Index action and in the CreateUser action, but I have a feeling there must be a better way. Thanks.

    Read the article

  • asp.net mvc custom routes with multiple submit buttons

    - by dangerisgo
    So I have a custom route as such: routes.MapRoute( "Wizard", // Route name "Wizard/{page}", // URL with parameters new { controller = "Wizard", action = "Index" } // Parameter defaults ); and have the following on my View: <% Html.BeginForm("Continue", "Wizard"); %> <input type="submit" value="Continue" name="Continue" /> <% Html.EndForm(); %> In which I want to call this function: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Continue(string Number, string Rev) { (...) } but in turn when that button is pressed always calls the postback Index rather than the one I want. If I remove the custom route, it calls my function, but what I want to be displayed in the address bar is: localhost:xxxx/Wizard/1 where the number at the end is the page (div shown) of the wizard either 1, 2, 3, or 4. So is there something I'm missing or can it not be done? Thanks.

    Read the article

  • what is wrong with this insert method in asp.net mvc?

    - by Pandiya Chendur
    My controller calls a repository class method on insert, [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind(Exclude = "Id")]FormCollection collection) { try { MaterialsObj materialsObj = new MaterialsObj(); materialsObj.Mat_Name = collection["Mat_Name"]; materialsObj.Mes_Id = Convert.ToInt64(collection["MeasurementType"]); materialsObj.Mes_Name = collection["Mat_Type"]; materialsObj.CreatedDate = System.DateTime.Now; materialsObj.CreatedBy = Convert.ToInt64(1); materialsObj.IsDeleted = Convert.ToInt64(1); consRepository.createMaterials(materialsObj); return RedirectToAction("Index"); } catch { return View(); } } and my repository class has this, public MaterialsObj createMaterials(MaterialsObj materialsObj) { db.Materials.InsertOnSubmit(materialsObj); return materialsObj; } But when i compile this i get The best overloaded method match for 'System.Data.Linq.Table<CrMVC.Models.Material>.InsertOnSubmit(CrMVC.Models.Material)' has some invalid arguments... cannot convert from 'CrMVC.BusinessObjects.MaterialsObj' to 'CrMVC.Models.Material'.. am i missing something?

    Read the article

  • Is it possible to use Dependency Injection/IoC on an ASP.NET MVC FilterAttribute ?

    - by Pure.Krome
    Hi folks, I've got a simple custom FilterAttribute which I use decorate various ActionMethods. eg. [AcceptVerbs(HttpVerbs.Get)] [MyCustomFilter] public ActionResult Bar(...) { ... } Now, I wish to add some logging to this CustomFilter Action .. so being a good boy, I'm using DI/IoC ... and as such wish to use this pattern for my custom FilterAttribute. So if i have the following... ILoggingService and wish to add this my custom FilterAttribute .. i'm not sure how. Like, it's easy for me to do the following... public class MyCustomFilterAttribute : FilterAttribute { public MyCustomFilterAttribute(ILoggingService loggingService) { ... } } But the compiler errors saying the attribute which decorates my ActionMethod (listed above...) requires 1 arg .. so i'm just not sure what to do :(

    Read the article

  • .NET - Retrieve attribute from controller context?

    - by ropstah
    I have a controller insert action: <AcceptVerbs(HttpVerbs.Post)> _ Function InsertObject(<Bind(Exclude:="Id")> <ModelBinder(GetType(CustomModelBinder))> ByVal object As SomeObject) As ActionResult End Function And i have a CustomModelBinder class with a BindModel implementation: Public Function BindModel( _ ByVal controllerContext As System.Web.Mvc.ControllerContext, _ ByVal bindingContext As System.Web.Mvc.ModelBindingContext) As Object Implements System.Web.Mvc.IModelBinder.BindModel For Each s In HttpContext.Current.Request.Form.Keys HttpContext.Current.Response.Write(s & ": " & HttpContext.Current.Request.Form(s) & "<br />") Next HttpContext.Current.Response.End() End Function As you can see I have a controllerContext and a ModelBindingContext available. How do I get the: <Bind(Exclude:="Id")> part inside the BindModel implementation?

    Read the article

  • testing the controller in asp.net mvc

    - by csetzkorn
    Hi, I would like to test the validation of submitted DTO. This is the bare bone of a controller create action: [AcceptVerbs(HttpVerbs.Post)] public RedirectToRouteResult Create(SomeDTO SomeDTO) { SomeObject SomeObject = null; try { SomeObject = this.RepositoryService.getSomeObjectRepository().Create(SomeDTO, this.RepositoryService); } catch (BrokenRulesException ex) { ex.AddModelStateErrors(ModelState, "Model"); } catch (Exception e) { ModelState.AddModelError("Exception", e.Message); } TempData["ViewData"] = ViewData; TempData["SomeDTO "] = SomeDTO; return ModelState.IsValid ? RedirectToAction("SomeObjectDetail", new { Id = SomeObject.Id }) : RedirectToAction("Form"); } The mechanics , although not relevant, is as follows: I have a strongly typed view = form which submits a dto to this action which either returns the form or the details page of the created object. I would like to unit test whether the Model contains certain key/errorMessage combinations given some invalid dto. Did someone do similar stuff? Any pointers would be very much appreciated. Thanks. Best wishes, Christian

    Read the article

  • Can I create a transaction using ADO NET Entity Data Model?

    - by Junior Mayhé
    Hi is it possible on the following try-catch to execute a set of statements as a transaction using ADO NET Entity Data Model? [ValidateInput(false)] [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Customer c) { try { c.Created = DateTime.Now; c.Active = true; c.FullName = Request.Form["FirstName"]; db.AddToCustomer(c); db.SaveChanges(); Log log = new Log();//another entity model object log.Created = DateTime.Now; log.Message = string.Format(@"A new customer was created with customerID {0}", c.CustomerID); db.AddToLog(log); db.SaveChanges(); return RedirectToAction("CreateSuccess", "Customer"); } catch { return View(); } } Any thoughts would be very appreciated.

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >