Search Results

Search found 53991 results on 2160 pages for 'asp net 3 5'.

Page 74/2160 | < Previous Page | 70 71 72 73 74 75 76 77 78 79 80 81  | Next Page >

  • Stored Procedure call with parameters in ASP.NET MVC

    - by cc0
    I have a working controller for another stored procedure in the database, but I am trying to test another. When I request the URL; http://host.com/Map?minLat=0&maxLat=50&minLng=0&maxLng=50 I get the following error message, which is understandable but I can't seem to find out why it occurs; Procedure or function 'esp_GetPlacesWithinGeoSpan' expects parameter '@MinLat', which was not supplied. This is the code I am using. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Mvc.Ajax; using System.Data; using System.Text; using System.Data.SqlClient; namespace prototype.Controllers { public class MapController : Controller { //Initial variable definitions //Array with chars to be used with the Trim() methods char[] lastComma = { ',' }; //Minimum and maximum lat/longs for queries float _minLat; float _maxLat; float _minLng; float _maxLng; //Creates stringbuilder object to store SQL results StringBuilder json = new StringBuilder(); //Defines which SQL-server to connect to, which database, and which user SqlConnection con = new SqlConnection(...connection string here...); // // HTTP-GET: /Map/ public string CallProcedure_getPlaces(float minLat, float maxLat, float minLng, float maxLng) { con.Open(); using (SqlCommand cmd = new SqlCommand("esp_GetPlacesWithinGeoSpan", con)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@MinLat", _minLat); cmd.Parameters.AddWithValue("@MaxLat", _maxLat); cmd.Parameters.AddWithValue("@MinLng", _minLng); cmd.Parameters.AddWithValue("@MaxLng", _maxLng); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { json.AppendFormat("\"{0}\":{{\"c\":{1},\"f\":{2}}},", reader["PlaceID"], reader["PlaceName"], reader["SquareID"]); } } con.Close(); } return "{" + json.ToString().TrimEnd(lastComma) + "}"; } //http://host.com/Map?minLat=0&maxLat=50&minLng=0&maxLng=50 public ActionResult Index(float minLat, float maxLat, float minLng, float maxLng) { _minLat = minLat; _maxLat = maxLat; _minLng = minLng; _maxLng = maxLng; return Content(CallProcedure_getPlaces(_minLat, _maxLat, _minLng, _maxLng)); } } } Any help on resolving this problem would be greatly appreciated.

    Read the article

  • Asp.Net MVC EditorTemplate Model is lost after Post

    - by Farrell
    I have a controller with two simple Methods: UserController Methods: [AcceptVerbs(HttpVerbs.Get)] public ActionResult Details(string id) { User user = UserRepo.UserByID(id); return View(user); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Details(User user) { return View(user); } Then there is one simple view for displaying the details: <% using (Html.BeginForm("Details", "User", FormMethod.Post)) {%> <fieldset> <legend>Userinfo</legend> <%= Html.EditorFor(m => m.Name, "LabelTextBoxValidation")%> <%= Html.EditorFor(m => m.Email, "LabelTextBoxValidation")%> <%= Html.EditorFor(m => m.Telephone, "LabelTextBoxValidation")%> </fieldset> <input type="submit" id="btnChange" value="Change" /> <% } %> As you can see, I use an editor template "LabelTextBoxValidation": <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %> <%= Html.Label("") %> <%= Html.TextBox(Model,Model)%> <%= Html.ValidationMessage("")%> Showing user information is no problem. The view renders perfectly user details. When I submit the form, the object user is lost. I debugged on the row "return View(User);" in the Post Details method, the user object is filled with nullable values. If I dont use the editor template, the user object is filled with correct data. So there has to be something wrong with the editor template, but can't figure out what it is. Suggestions?

    Read the article

  • ASP.NET MVC Page - hyper links in HTML.ValidationSummary

    - by Rita
    Hi I have Registration page and if the validation fails, it displays the error messages using HTML.ValidationSummary control. Now i have to display the Hyperlink in that Validation Error Message. But it is treating href also as string. The Validation Message that I am trying to display with hyperlink is: **"User already exists in the system, please <a href='../Login.aspx'>login</a>"** Appreciate your responses. Here is my Code: <% using (Html.BeginForm()) {%> <%= Html.ValidationSummary(false) %> <fieldset> <div class="cssform">; <p> <%= Html.LabelFor(model => model.email)%><em>*</em> <%= Html.TextBoxFor(model => model.email, new { @class = "required email" })%> <%= Html.ValidationMessageFor(model => model.email)%> </p> <p> <%= Html.Label("Confirm email")%><em>*</em> <%= Html.TextBox("confirm_email")%> <%= Html.ValidationMessage("confirm_email") %> </p> <p> <%= Html.Label("Password")%><em>*</em> <%= Html.Password("Password", null, new { @class = "required" })%> <%= Html.ValidationMessage("Password")%><br /> (Note: Password should be minimum 6 characters) </p> <p> <%= Html.Label("Confirm Password")%><em>*</em> <%= Html.Password("confirm_password")%> <%= Html.ValidationMessage("confirm_password") %> </p><hr /> <% } %

    Read the article

  • asp.net mvc tree view with checkbox

    - by mazhar
    Ok I am looking for a solution in mvc2 where i can have tree view generated where after that i can checked the nodes I want to enter the value in the database. Can anyone point me to something? Basically I am assigning features to a particular group.(I have a group admin whom I can assign the manage user add edit delete,manage groups delete,manage teacher add edit feature Can someone point me to some other technique that i can implement?

    Read the article

  • ASP.NET MVC: routing help

    - by pcampbell
    Consider two methods on the controller CustomerController.cs: //URL to be http://mysite/Customer/ public ActionResult Index() { return View("ListCustomers"); } //URL to be http://mysite/Customer/8 public ActionResult View(int id) { return View("ViewCustomer"); } How would you setup your routes to accommodate this requirement? How would you use Html.ActionLink when creating a link to the View page?

    Read the article

  • ASP.NET MVC Class level custom data-annotation and ModelState keys

    - by Neil
    Hi, I have custom class level validation attribute, inheriting from ValidationAttribute, on my model. How come it doesn't register a key in the ModelState when its IsValid is false? I can see the the error message in the ModelState.Values collection, but the ModelState.Keys collection only shows an empty string "". Can I provide a key for it - presumably this is because its not assigned to a property? I wanna be able to use ModelState.Remove in my controller to remove this error upon a certain condition, but I have no Key! Any ideas?

    Read the article

  • ASP.NET MVC 2 - ViewModel Prefix

    - by Cosmo
    I want to use RenderPartial twice in my view with different models associated. The problem is that some properties are present in both models (nickname, password). They have no prefix, so even the id's or names are equal in the output. Now, if I have model errors for nickname or password, both fields get highlighted. Main View: <div> <% Html.RenderPartial("Register", Model.RegisterModel); %> </div> <div> <% Html.RenderPartial("Login", Model.LoginModel); %> </div> Login PartialView: <% using (Html.BeginForm("Login", "Member")) { %> <fieldset> <legend>Login</legend> <p> <%= Html.LabelFor(x => x.Nickname) %> <%= Html.TextBoxFor(x => x.Nickname) %> </p> <p> <%= Html.LabelFor(x => x.Password) %> <%= Html.PasswordFor(x => x.Password) %> </p> <input type="submit" value="Login" /> </fieldset> <% } % Register PartialView: <% using (Html.BeginForm("Register", "Member")) { %> <fieldset> <legend>Register</legend> <p> <%= Html.LabelFor(x => x.Nickname) %> <%= Html.TextBoxFor(x => x.Nickname) %> </p> <p> <%= Html.LabelFor(x => x.Email) %> <%= Html.TextBoxFor(x => x.Email) %> </p> <p> <%= Html.LabelFor(x => x.Password) %> <%= Html.PasswordFor(x => x.Password) %> </p> <p> <%= Html.LabelFor(x => x.PasswordRepeat) %> <%= Html.PasswordFor(x => x.PasswordRepeat) %> </p> <input type="submit" value="Register" /> </fieldset> <% } % How can I change this?

    Read the article

  • Building a template to auto-scaffold Index views in ASP.NET MVC

    - by DanM
    I'm trying to write an auto-scaffolder for Index views. I'd like to be able to pass in a collection of models or view-models (e.g., IQueryable<MyViewModel>) and get back an HTML table that uses the DisplayName attribute for the headings (th elements) and Html.Display(propertyName) for the cells (td elements). Each row should correspond to one item in the collection. Here's what I have so far: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <% var items = (IQueryable<TestProj.ViewModels.TestViewModel>)Model; // Should be generic! var properties = items.First().GetMetadata().Properties .Where(pm => pm.ShowForDisplay && !ViewData.TemplateInfo.Visited(pm)); %> <table> <tr> <% foreach(var property in properties) { %> <th> <%= property.DisplayName %> </th> <% } %> </tr> <% foreach(var item in items) { %> <tr> <% foreach(var property in properties) { %> <td> <%= Html.Display(property.DisplayName) %> // This doesn't work! </td> <% } %> </tr> <% } %> </table> Two problems with this: I'd like it to be generic. So, I'd like to replace var items = (IQueryable<TestProj.ViewModels.TestViewModel>)Model; with var items = (IQueryable<T>)Model; or something to that effect. The <td> elements are not working because the Html in <%= Html.Display(property.DisplayName) %> contains the model for the view, which is a collection of items, not the item itself. Somehow, I need to obtain an HtmlHelper object whose Model property is the current item, but I'm not sure how to do that. How do I solve these two problems?

    Read the article

  • ASP MVC2 model binding issue on POST

    - by Brandon Linton
    So I'm looking at moving from MVC 1.0 to MVC 2.0 RTM. One of the conventions I'd like to start following is using the strongly-typed HTML helpers for generating controls like text boxes. However, it looks like it won't be an easy jump. I tried migrating my first form, replacing lines like this: <%= Html.TextBox("FirstName", Model.Data.FirstName, new {maxlength = 30}) %> ...for lines like this: <%= Html.TextBoxFor(x => x.Data.FirstName, new {maxlength = 30}) %> Previously, this would map into its appropriate view model on a POST, using the following method signature: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Registration(AccountViewInfo viewInfo) Instead, it currently gets an empty object back. I believe the disconnect is in the fact that we pass the view model into a larger aggregate object that has some page metadata and other fun stuff along with it (hence x.Data.FirstName instead of x.FirstName). So my question is: what is the best way to use the strongly-typed helpers while still allowing the MVC framework to appropriately cast the form collection to my view-model as it does in the original line? Is there any way to do it without changing the aggregate type we pass to the view? Thanks!

    Read the article

  • Standard way to persist data between requests in ASP.NET-MVC

    - by Nate Bross
    What is the most standard or best way to persist data between requests? Should I use cookies or session variables? I'm interested in keeping data like sort order, sort column, and page number (for paginiation). I'm coming from a webforms background so normally this type of thing was automatically handled for me in the viewstate of the controls I was using.

    Read the article

  • asp.net mvc custom model binder

    - by mike
    pleas help guys, my custom model binder which has been working perfectly has starting giving me errors details below An item with the same key has already been added. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: An item with the same key has already been added. Source Error: Line 31: { Line 32: string key = bindingContext.ModelName; Line 33: var doc = base.BindModel(controllerContext, bindingContext) as Document; Line 34: Line 35: // DoBasicValidation(bindingContext, doc); Source File: C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Web\Binders\DocumentModelBinder.cs Line: 33 Stack Trace: [ArgumentException: An item with the same key has already been added.] System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +51 System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) +7462172 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) +270 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, IEqualityComparer1 comparer) +102 System.Web.Mvc.ModelBindingContext.get_PropertyMetadata() +157 System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +158 System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +90 System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +50 System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1048 System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +280 PitchPortal.Web.Binders.documentModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) in C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Web\Binders\DocumentModelBinder.cs:33 System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +257 System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +109 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +314 System.Web.Mvc.Controller.ExecuteCore() +105 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.<c_DisplayClass8.b_4() +34 System.Web.Mvc.Async.<c_DisplayClass1.b_0() +21 System.Web.Mvc.Async.<c_DisplayClass81.b_7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult1.End() +59 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8677678 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 any ideas guys? Thanks

    Read the article

  • ASP.NET MVC Route Default values

    - by Sadegh
    hi, i defined two routes in global.asax like below context.MapRoute("HomeRedirect", "", new { controller = "Home", action = "redirect" }); context.MapRoute("UrlResolver", "{culture}/some", new { culture = "en-gb", controller = "someController", action = "someAction" }, new { culture = new CultureRouteConstraint() }); according to above definition, when user request mysite.com/ redirect action of HomeController should be called and in that: public class HomeController : Controller { public ActionResult Redirect() { return RedirectToRoute("UrlResolver"); } } i want to redirect user to second defined route on above, so also i specified default values for that and some Constraint for each of those. but when RedirectToRoute("UrlResolver") turns, no default values passed to routeConstraints on second route and No route in the route table matches the supplied values shows. update my CultureRouteConstraint: public class CultureRouteConstraint : IRouteConstraint { bool IRouteConstraint.Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { try { var parameter = values[parameterName] as string; return (someCondition(parameter)); } catch { return false; } } } now values parameter haven't culture key/value, but route parameter have that.

    Read the article

  • Castle Windsor with ASP.NET MVC 2 Areas

    - by Doug Shontz
    Been lurking for a few months and decided to jump in with a question. I am very new to Windsor and IoC in general. I can get Windsor to work with my MVC2 project with no problem. The project I am working on is a "portal" of multiple applications under one MVC2 project using the new Areas concept. In this scenario, each Area will actually be a separate application inside the "portal". We are doing this to effectively share a LOT of common code, views, authentication, and cross-application functionality. Many of our apps link to one another, so it made sense after discussing it to combine them into one project. What I am wondering how to do is actually allow different Areas to inject different concrete classes? In my limited understanding, the Application_Start is governing building the container and assigning it as the controller factory. I don't necessarily want to do all the injection at the application level. We have a config system where we have a config.xml at the root of every Area and those settings override any root settings. I would like to continue that trend by having the injections for each Area be read by the Area's config.xml (an inheritance similar to Webforms web.config where the config in a lower folder overrides settings in a parent folder). Example: I would have an ILogHandler which would need a different concrete implementation depending on which Area of the application I am in. So I would need to inject something different depending on where I am at in the application. I can easily do this using factories since each area could have it's own set of factories, but I am attempting to take this opportunity to learn about IoC and what the benefits/drawbacks are. Any help would be appreciated.

    Read the article

  • Visual Studio 2010 Full and ASP.NET MVC 2.0 Template

    - by Daniel
    Hello, I've installed full version (not RC nor Beta) of Visual Studio 2010, a then setup within Web Platform Installer 2.0 announce me that I need to install MVC 2.0, so i did it. When I want to create project "MvcWebApplicationProjectTemplate" in VS I have following message: error: this template attempted to load component assembly 'Microsoft.VisualStudio.Web.Mvc.2.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. For more information on this problem and how to enable this template, please see documentation on Customizing Project Templates. Any idea how to fix it? Do you think that Web Platform Installer 2.0 might have corrupted this template? Thanks, Daniel

    Read the article

  • asp.net mvc ajax

    - by mazhar kaunain baig
    <% using (Ajax.BeginForm("EditOrganizationMeta", new AjaxOptions { UpdateTargetId = "\<%= OrganizationMeta.vcr_MetaKey + Lang.int_LangId%>" })) { %> i want to specify name after UpdateTargetid ,how will i do that?

    Read the article

  • How to pass data between pages without sessions in ASP.net MVC

    - by Ashwani K
    Hello All: I have one application in which I want to pass data between Pages (Views) without sessions. Actually I want to apply some settings to all the pages using query string. For example if my link is like "http://example.com?data=test1", then I want to append this query string to all the link there after and if there is no query string then normal flow. I was thinking if there is any way that if we get the query string in any link for the web application then some application level user specific property can be set which can be used for subsequent pages. Thanks, Ashwani

    Read the article

  • Auto-scaffolding an "index" view in ASP.NET MVC

    - by DanM
    I'm trying to write an auto-scaffolder for Index views. I'd like to be able to pass in a collection of models or view-models (e.g., IQueryable<MyViewModel>) and get back an HTML table that uses the DisplayName attribute for the headings (th elements) and Html.Display(propertyName) for the cells (td elements). Each row should correspond to one item in the collection. Here's what I have so far: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <% var items = (IQueryable<TestProj.ViewModels.TestViewModel>)Model; // Should be generic! var properties = items.First().GetMetadata().Properties .Where(pm => pm.ShowForDisplay && !ViewData.TemplateInfo.Visited(pm)); %> <table> <tr> <% foreach(var property in properties) { %> <th> <%= property.DisplayName %> </th> <% } %> </tr> <% foreach(var item in items) { %> <tr> <% foreach(var property in properties) { %> <td> <%= Html.Display(property.DisplayName) %> // This doesn't work! </td> <% } %> </tr> <% } %> </table> Two problems with this: I'd like it to be generic. So, I'd like to replace var items = (IQueryable<TestProj.ViewModels.TestViewModel>)Model; with var items = (IQueryable<T>)Model; or something to that effect. The <td> elements are not working because the Html in <%= Html.Display(property.DisplayName) %> contains the model for the view, which is a collection of items, not the item itself. Somehow, I need to obtain an HtmlHelper object whose Model property is the current item, but I'm not sure how to do that. How do I solve these two problems?

    Read the article

  • ASP.Net MVC Keeping action parameters between postbacks

    - by Matt
    Say I have a page that display search results. I search for stackoverflow and it returns 5000 results, 10 per page. Now I find myself doing this when building links on that page: <%=Html.ActionLink("Page 1", "Search", new { query=ViewData["query"], page etc..%> <%=Html.ActionLink("Page 2", "Search", new { query=ViewData["query"], page etc..%> <%=Html.ActionLink("Page 3", "Search", new { query=ViewData["query"], page etc..%> <%=Html.ActionLink("Next", "Search", new { query=ViewData["query"], page etc..%> I dont like this, I have to build my links with careful consideration to what was posted previously etc.. What I'd like to do is <%=Html.BuildActionLinkUsingCurrentActionPostData ("Next", "Search", new { Page = 1}); where the anonymous dictionary overrides anything currently set by previous action. Essentially I care about what the previous action parameters were, because I want to reuse, it sounds simple, but start adding sort and loads of advance search options and it starts getting messy. Im probably missing something obvious

    Read the article

  • ASP.NET MVC 2 RTM - favicon not displayed in Internet Explorer

    - by hungster
    I have the following two lines in the head section in my masterpage: <link rel="shortcut icon" href="/Content/Images/favicon.ico" type="image/x-icon" /> <link rel="icon" href="/Content/Images/favicon.ico" type="image/ico" /> However, the favicon is not displayed in Internet Explorer (version 6, 7, 8). In Firefox and Safari the favicon works fine. I have even tried to replace href with the URL to my website (http://www......./Content/Images/favicon.ico) but that still does not work in Internet Explorer. Am I missing something?

    Read the article

  • ASP.NET MVC 2 RC2 Model Binding with NVARCHAR NOT NULL column

    - by Gary McGill
    I have a database column defined as NVARCHAR(1000) NOT NULL DEFAULT(N'') - in other words, a non-nullable text column with a default value of blank. I have a model class generated by the Linq-to-SQL Classes designer, which correctly identifies the property as not nullable. I have a TextAreaFor in my view for that property. I'm using UpdateModel in my controller to fetch the value from the form and populate the model object. If I view the web page and leave the text area blank, UpdateModel insists on setting the property to NULL instead of empty string. (Even if I set the value to blank in code prior to calling UpdateModel, it still overwrites that with NULL). Which, of course, causes the subsequent database update to fail. I could check all such properties for NULL after calling UpdateModel, but that seems ridiculous - surely there must be a better way? Please don't tell me I need a custom model binder for such a simple scenario...!

    Read the article

  • ASP.NET MVC 2 Post AJAX from from JavaScript

    - by ANDyW
    Hi, I got control with strongly typed View, with Ajax.BeginForm(). Now I would like to change submit method from <input type="submit" id="testClick" value="Submit" /> To some javascript method DoSubmit(). What I tried is : Invoke click on that submit button Invoke submit on form ('form1').submit(), document.forms['form1'].submit() jQuery forms with ('form1').AjaxSubmit(); Create jQuery AJAX $.ajax({ type: "POST", url: $("#form1").attr("action"), data: $("#form1").serialize(), success: function() { alert("epic win!!!1!1!") }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert("epic fail!") } }); All those method created normal request (not AJAX), or they didn't work. So anyone know how I can do AJAX submit "Form", from JavaScript and strongly typed mechanism (public AcrionResult MyFormAction(FormModel model); ) will work?

    Read the article

< Previous Page | 70 71 72 73 74 75 76 77 78 79 80 81  | Next Page >