Search Results

Search found 57033 results on 2282 pages for 'asp net mvc 2 metadata'.

Page 80/2282 | < Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >

  • Comparing ASP.Net Framework to Cakephp, Zend , Ruby on Rails

    - by numerical25
    I am a PHP developer migrating to C# ASP.Net Framework. As of right now, I am experienced in using Php for developing sites and I use CakePhp and Zend framework as my RAD tools to help me produce better applications. As I move over to ASP.NET, I have this view that C# ASP.Net framework itself is already a RAD tool and is equivalent to using Cakephp, Zend, or even Ruby on Rails. So I really shouldn't have no concerns trying to find a separate library for ASP.NET that will help me produce better applications. To me, in a sense the ASP.NET is already like a MVC cause it seperates the model from the view and the methods are almost like controllers. So as far as having the best tools are concerned, should I be satisfied with just using ASP.NET as my RAD tool.

    Read the article

  • Best placement for javascript in Asp.net MVC app that heavily uses partial views

    - by KallDrexx
    What is the best place for javascript that is specific to a partial view? For example, if I have a partial view (loaded via ajax call) with some divs and I want to turn those divs into an accordian, would it be better put the $("#section").accordion() in script tags inside of the partial view, or in a .js file in the function that retrieves that partial view and inserts it into the DOM? Obviously, common methods I will be keeping in a .js file, however I am more talking about javascript very specific to the partial view itself. Most things I find on the net seem to say to put all javascript into a separate .js but nothing addresses the idea of partial views.

    Read the article

  • ASP.Net Error - Unable to cast object of type 'System.String' to type 'System.Data.DataTable'.

    - by xtrabits
    I get the below error Unable to cast object of type 'System.String' to type 'System.Data.DataTable'. This is the code I'm using Dim str As String = String.Empty If (Session("Brief") IsNot Nothing) Then Dim dt As DataTable = Session("Brief") If (dt.Rows.Count > 0) Then For Each dr As DataRow In dt.Rows If (str.Length > 0) Then str += "," str += dr("talentID").ToString() Next End If End If Return str Thanks

    Read the article

  • Adding childs to list of parents with jquery /mvc2

    - by John Landheer
    Hi, I have a table of products on my page, each product has zero or more colors, the colors are shown as a list beneath the product. After the colors I have a button to add a color. The button will do an ajax call with the parent product id to a controller which will return a JSON object with color information. My problem is where to store the product id in the DOM, should I put it in a hidden field and use jquery in the click event of the "add color" to get to it? What is the best way to do this? TIA, John EDIT: The page is initially rendered on the server so I don't want to use jquery to add the id's to the page.

    Read the article

  • Does Security Trimming work with Web Forms Routing?

    - by Slauma
    In my web.config I have configured a SiteMapProvider with securityTrimmingEnabled="true" and on my main master page is an asp:Menu control bound to an asp:SiteMapDataSource. In addition I have configured restricted access to all pages in a subfolder "Admin" (using another web.config in this subfolder). If I put a sitemapNode in Web.sitemap... <siteMapNode url="~/Admin/Default.aspx" title="Administration" description="" > ... only users in role "Admin" will have the menu item related to that siteMapNode. So this is working fine and as intended. Now I have defined a URL route in Global.asax to map the physical file to a new URL: System.Web.Routing.RouteTable.Routes.MapPageRoute("AdminHomeRoute", "Administration/Home", "~/Admin/Default.aspx"); But when I use this route-URL in the SiteMap file... <siteMapNode url="Administration/Home" title="Administration" description="" > ... it seems that security trimming does not work: The menu item is visible for all users. (Access to the page is still restricted though, so selecting the menu item by non-Admin users does not navigate to the restricted page.) Question: Is there any setting I've missed so far to make security trimming working with URL routing in ASP.NET 4.0 Web Forms? Did I do something wrong? Is there any work-around? Thank you for help!

    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

  • in asp.net linking two webpages and one of them has emails which an user can select who they want to

    - by user305112
    I have two pages in the first page i have a button called emails. when the user clicks on the email button it will take them to the emails pages and there i have 12 checkboxes and a OK button. the user can select as many checkboxes as they want. the checkboxes have peoples email in them. after they select it they click on the OK button and which will take them to the page1.aspx where they will fill rest of the information out and when they clicked on the emails button and came back to the page1 it will not erase any of their information. I have redirected the page to emails and back to page1 but i don't know how to save the checked emails from the emails page and clicking OK and taking back to the page1 so the other information on that page is already there not been erased.

    Read the article

  • Error while updating Database record with Entity Framework on ASP.NET MVC Page

    - by Rupa
    Hi I have an ASP.NET Page that updates registered User Address Details for a selected record. Below is the Update method that i am calling from Controller. When i am calling ApplyPropertyChanges method, I am getting the below error. Did anyone run into the same error while updating the record with Entity Framework. Appreciate your responses. Error Message: The existing object in the ObjectContext is in the Added state. Changes can only be applied when the existing object is in an unchanged or modified state. My Update Method Code: [HttpPost] public bool UpdateAddressDetail([Bind(Prefix = "RegUser")] AddressDetail regUserAddress, FormCollection formData) { regUserAddress.AD_Id = 3; regUserAddress.LastUpdated = HttpContext.User.Identity.Name; regUserAddress.UpdatedOn = DateTime.Now; regUserAddress.AddressType = ((AddressDetail)Session["CurrentAddress"]).AddressType ?? "Primary"; regUserAddress.Phone = ((AddressDetail)Session["CurrentAddress"]).Phone; regUserAddress.Country = ((AddressDetail)Session["CurrentAddress"]).AddressType ?? "USA"; miEntity.ApplyPropertyChanges(regUserAddress.EntityKey.EntitySetName, regUserAddress); miEntity.SaveChanges(); return true; }

    Read the article

  • Unobtrusive Client Validation without accepting model

    - by user1010609
    I have simple form like this which accepts only two values string action and editText.Is there a way to enable Unobtrusive Client Validation on this without Data Annotations? Or do I have to accept model and use Data Annotations? I just need it to make sure editText is atleast 5 chars long. @using (Ajax.BeginForm("Action", "Controller", null, new AjaxOptions { OnFailure = "error", UpdateTargetId = "Pcedit" + @Model.ID})) { <textarea rows="3" cols="2" name="editText" style="width:100%;"></textarea> <br /> <input type="submit" name="action" value="Save"/> <input type="submit" name="action" value="Cancel"/> }

    Read the article

  • What Controller/Action will this go to?

    - by rkrauter
    Assume this is the first route entry: routes.MapRoute( "myRoute", "employees/{city}/{pageNumber}", new { controller="Employees", action = "List", pageNumber = 1 } ); If I make the following request employees/london/2 it gets matched to the following action method: public ActionResult List(string city) {} How did that happen? I did not specify "city" in my object defaults: new { controller="Employees", action = "List", pageNumber = 1 } Please explain. Thanks!

    Read the article

  • Similar route mapping

    - by Denis Agarev
    I need to map to create controller what must response to two urls: "http://localhost/api/controller?id=1" (where only id value can change) "http://localhost/api/controller/anotherId/someconst" (where anotherId is the only one changing part) i map it to such route: routes.MapHttpRoute("Test", "api/{controller}/{id}/{someconst}", new { controller = "Test", someconst = RouteParameter.Optional }); And have to methods in my controller: public void Get(int id) { ... } public void Get(int anotherId, string someconst ) { ... } It works...But it doesn't look nice...cause "string someconst" is not a param, it's just a const part of url. But if i remove "string someconst" param second url wouldn't work. Is it possible to map one controller to two routes to resolve this urls to make it clear without fake param which is a const in fact?

    Read the article

  • How does Model binding with a selectlist work?

    - by rsteckly
    Hi, I'm having problems retrieving the values of a selectlist in my form collection. I've tried making a viewmodel with an attribute with the same name as the select list. I'm honestly just realizing I REALLY don't understand how model binding works with selectlists. I've just been assuming that the following conventions apply: Name the select list the same thing as the attribute on the model you want it to bind to. Apart from that, I really don't get it. I've looked at several books on it and they're useless frankly. How does a select list work with a) form collection and b) a particular model?

    Read the article

  • ASP.NET MVC Membership, Get new UserID

    - by Vishal Bharakhda
    I am trying to register a new user and also understand how to get the new userID so i can start creating my own user tables with a userID mapping to the asp.net membership user table. Below is my code: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Register(string userName, string email, string position, string password, string confirmPassword) { ViewData["PasswordLength"] = MembershipService.MinPasswordLength; ViewData["position"] = new SelectList(GetDeveloperPositionList()); if (ValidateRegistration(userName, email, position, password, confirmPassword)) { // Attempt to register the user MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email); if (createStatus == MembershipCreateStatus.Success) { FormsAuth.SignIn(userName, false /* createPersistentCookie */); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus)); } } // If we got this far, something failed, redisplay form return View(); } I've done some research and many sites inform me to use Membership.GetUser().ProviderUserKey; but this throws an error as Membership is NULL. I placed this line of code just above "return RedirectToAction("Index", "Home");" within the if statement. Please can someone advise me on this... Thanks in advance

    Read the article

  • How to set the returnURL manually when using Ajax.ActionLink

    - by Roge
    I have this link @Ajax.ActionLink("create poll question", "CreatePoll", new { id = Model.DebateID }, new AjaxOptions { UpdateTargetId = "poll-entry-box", InsertionMode = InsertionMode.Replace, HttpMethod = "GET" }) which is pointing at a action with the [Authorize] Attribute. The login works, but the returnURL is empty so it just redirects to the index page. Is there some way to manually set the returnURL ? NOTE I am using the method described here http://haacked.com/archive/2011/10/04/prevent-forms-authentication-login-page-redirect-when-you-donrsquot-want.aspx because the login page was loading inside my partial.

    Read the article

  • How to show ModelState.AddModelError when the Model is Empty in MVC4

    - by kk1076
    I am displaying a shopping cart. I need to check for empty values in Shopping cart and display a message like "The Shopping Cart is empty". When I use ModelState.AddModelError in myAction, it throws an exception as there is null reference in Model. How to display the ErrorMessage. My Action public ActionResult Index() { string id = Request.QueryString["UserID"]; IList<CartModel> objshop = new List<CartModel>(); objshop = GetCartDetails(id); if (objshop.Count > 0) { return View(objshop.ToList()); } else { ModelState.AddModelError("", "Your Shopping Cart is empty!"); } return View(); } My View @{ @Html.ValidationSummary(true) } <th > @Html.DisplayNameFor(model => model.ProductName) </th> <th > @Html.DisplayNameFor(model => model.Quantity) </th> <th > @Html.DisplayNameFor(model => model.Rate) </th> <th > @Html.DisplayNameFor(model => model.Price) </th> @foreach (var item in Model) { <td> @Html.DisplayFor(modelItem => item.ProductName)</td> <td> @Html.DisplayFor(modelItem => item.Quantity)</td> <td> @Html.DisplayFor(modelItem => item.Rate) </td> <td> @Html.DisplayFor(modelItem => item.Price) </td> } Any suggestions.

    Read the article

  • Is C# WebAPI worth it? Can I use standart MVC4 to create my API?

    - by Steve
    I need to build a massive API and I'm trying out WebAPI instead of default MVC4 projects and it seems that it just makes things more difficult. Can have only 4 methods in controller Get, Post, Put, Delete, if I want more I need to modify route for that particular method FluentValidation won't work with WebAPI so I need to use DataAnnotations which I really don't want to. Can't use dynamic return data-types My question is: Would it really be that bad if I would use MVC4 project and use default ActionResults that return Json? What are real advantages of using WebAPI, why did they even made them in the first place if you can easily convert your project to API?

    Read the article

  • MVC4 Model in View has nested data - cannot get data in model

    - by Taersious
    I have a Model defined that gets me a View with a list of RadioButtons, per IEnumerable. Within that Model, I want to display a list of checkboxes that will vary based on the item selected. Finally, there will be a Textarea in the same view once the user has selected from the available checkboxes, with some dynamic text there based on the CheckBoxes that are selected. What we should end up with is a Table-per-hierarchy. The layout is such that the RadioButtonList is in the first table cell, the CheckBoxList is in the middle table cell, and the Textarea is ini the right table cell. If anyone can guide me to what my model-view should be to achieve this result, I'll be most pleased... Here are my codes: // // View Model for implementing radio button list public class RadioButtonViewModel { // objects public List<RadioButtonItem> RadioButtonList { get; set; } public string SelectedRadioButton { get; set; } } // // Object for handling each radio button public class RadioButtonItem { // this object public string Name { get; set; } public bool Selected { get; set; } public int ObjectId { get; set; } // columns public virtual IEnumerable<CheckBoxItem> CheckBoxItems { get; set; } } // // Object for handling each checkbox public class CheckBoxViewModel { public List<CheckBoxItem> CheckBoxList { get; set; } } // // Object for handling each check box public class CheckBoxItem { public string Name { get; set; } public bool Selected { get; set; } public int ObjectId { get; set; } public virtual RadioButtonItem RadioButtonItem { get; set; } } and the view @model IEnumerable<EF_Utility.Models.RadioButtonItem> @{ ViewBag.Title = "Connect"; ViewBag.Selected = Request["name"] != null ? Request["name"].ToString() : ""; } @using (Html.BeginForm("Objects" , "Home", FormMethod.Post) ){ @Html.ValidationSummary(true) <table> <tbody> <tr> <td style="border: 1px solid grey; vertical-align:top;"> <table> <tbody> <tr> <th style="text-align:left; width: 50px;">Select</th> <th style="text-align:left;">View or Table Name</th> </tr> @{ foreach (EF_Utility.Models.RadioButtonItem item in @Model ) { <tr> <td> @Html.RadioButton("RadioButtonViewModel.SelectedRadioButton", item.Name, ViewBag.Selected == item.Name ? true : item.Selected, new { @onclick = "this.form.action='/Home/Connect?name=" + item.Name + "'; this.form.submit(); " }) </td> <td> @Html.DisplayFor(i => item.Name) </td> </tr> } } </tbody> </table> </td> <td style="border: 1px solid grey; width: 220px; vertical-align:top; @(ViewBag.Selected == "" ? "display:none;" : "")"> <table> <tbody> <tr> <th>Column </th> </tr> <tr> <td><!-- checkboxes will go here --> </td> </tr> </tbody> </table> </td> <td style="border: 1px solid grey; vertical-align:top; @(ViewBag.Selected == "" ? "display:none;" : "")"> <textarea name="output" id="output" rows="24" cols="48"></textarea> </td> </tr> </tbody> </table> } and the relevant controller public ActionResult Connect() { /* TEST SESSION FIRST*/ if( Session["connstr"] == null) return RedirectToAction("Index"); else { ViewBag.Message = ""; ViewBag.ConnectionString = Server.UrlDecode( Session["connstr"].ToString() ); ViewBag.Server = ParseConnectionString( ViewBag.ConnectionString, "Data Source" ); ViewBag.Database = ParseConnectionString( ViewBag.ConnectionString, "Initial Catalog" ); using( var db = new SysDbContext(ViewBag.ConnectionString)) { var objects = db.Set<SqlObject>().ToArray(); var model = objects .Select( o => new RadioButtonItem { Name = o.Name, Selected = false, ObjectId = o.Object_Id, CheckBoxItems = Enumerable.Empty<EF_Utility.Models.CheckBoxItem>() } ) .OrderBy( rb => rb.Name ); return View( model ); } } } What I am missing it seems, is the code in my Connect() method that will bring the data context forward; at that point, it should be fairly straight-forward to set up the Html for the View. EDIT ** So I am going to need to bind the RadioButtonItem to the view with something like the following, except my CheckBoxList will NOT be an empty set. // // POST: /Home/Connect/ [HttpPost] public ActionResult Connect( RadioButtonItem rbl ) { /* TEST SESSION FIRST*/ if ( Session["connstr"] == null ) return RedirectToAction( "Index" ); else { ViewBag.Message = ""; ViewBag.ConnectionString = Server.UrlDecode( Session["connstr"].ToString() ); ViewBag.Server = ParseConnectionString( ViewBag.ConnectionString, "Data Source" ); ViewBag.Database = ParseConnectionString( ViewBag.ConnectionString, "Initial Catalog" ); using ( var db = new SysDbContext( ViewBag.ConnectionString ) ) { var objects = db.Set<SqlObject>().ToArray(); var model = objects .Select( o => new RadioButtonItem { Name = o.Name, Selected = false, ObjectId = o.Object_Id, CheckBoxItems = Enumerable.Empty<EF_Utility.Models.CheckBoxItem>() } ) .OrderBy( rb => rb.Name ); return View( model ); } } }

    Read the article

  • Razor support of generic extension methods

    - by Brian
    Hello, With regards to the Razor view engine, say I want to render Html.TextBoxFor<SomeModel>(i => i.Name), it doesn't seem that the inline syntax works as in: @Html.TextBoxFor<SomeModel>(i => i.Name) This doesn't seem to work because it interprets the generic as an HTML tag. I could use a code-block approach, but then what's the best approach to output the content? The HTML string returned from this method, do I response.write it, or is there a syntax for it, or what's the approach? Thanks.

    Read the article

  • Is it possible to specify Jquery File Upload to post back only once (for multiple files)?

    - by JaJ
    When I upload multiple files (per bluimp jquery file upload) the [httppost] action is entered once per file. Is it possible to specify one and only one postback with an enumerated file container to iterate? View: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="@Url.Content("~/Scripts/jquery.ui.widget.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.iframe-transport.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.fileupload.js")" type="text/javascript"></script> <input id="fileupload" type="file" name="files" multiple="multiple"/> Controller: public ActionResult Index() { return View(); } [HttpPost] public ActionResult Index(IEnumerable<HttpPostedFileBase> files) { // This is posted back for every file that gets uploaded...I would prefer it only post back once // with a actual collection of files to iterate. foreach (var file in files) // There is only ever one file in files { var filename = Path.Combine(Server.MapPath("~/App_Data"), file.FileName); file.SaveAs(filename); } return View(); }

    Read the article

  • Pattern to iterate Request Params

    - by NOOBie
    My view is not a strongly typed view and I need to iterate through Request Params in the controller action to determine the values posted. Is there a better way to iterate through the nameValueCollection AllKeys? I am currently looping through the Request Params and setting values appropriately. foreach (var key in Request.Params.AllKeys) { if (key.Equals("CustomerId")) queryObject.CustomerId = Request.Params[key]; else if (key.Equals("OrderId")) queryObject.OrderId= Request.Params[key]; //and so on } I see a considerable amount of repetition in this code. Is there a better way to handle this?

    Read the article

  • How do you handle ajax requests when user is not authenticated?

    - by LukLed
    How do you handle ajax requests when user is not authenticated? Someone enters the page, leaves room for an hour, returns, adds comment on the page that goes throuh ajax using jQuery ($.post). Since he is not authenticated, method return RedirectToRoute result (redirects to login page). What do you do with it? How do you handle it on client side and how do you handle it in controller?

    Read the article

  • Jquery validation in asp.net mvc

    - by Suja
    I have a view to create a DocumentTemplate <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" % <%@ Import Namespace="HexsolveMVC.Helpers" % Create <script type="text/javascript"> $(document).ready(function() { $("#reset").click(function(event) { $("#Part").get(0).selectedIndex = 0; $("#txtDocTitle").val(""); $("#txtarDocDesc").val(""); }); }); }); </script> <div class="container"> <div class="outer"> <div class="main_content"> <div> <%=Html.BreadCrumb(Model.BreadCrumbs)%> </div> <div class="form_container"> <h1> Document Template</h1> <ul> <li> <label> <span class="mandatory">*</span>Engine model:</label> <%=Html.DropDownList("Part", (SelectList)ViewData["Part"])%> <span class="tagline">Please select the engine model <%--<a href="#">Need Help</a>--%></span> </li> <li> <label> <span class="mandatory">*</span>Document Title:</label> <input id="txtDocTitle" name="docTitle" type="text" class="formstyle" /> </li> <li> <label> Discription:</label> <textarea name="docDesc" id="txtarDocDesc" cols="45" rows="5"></textarea> </li> <li> <div class="button_panel"> <input name="button" type="submit" class="btn_create_doc_big" id="button" value="Create" /> <span class="reset_field"><a href="#" id="reset">Reset the form</a></span><span class="mandatory_tag">[ <span class="mandatory">*</span> Mandatory fields ]</span> <div class="clear"> </div> </div> <span class="tagline">By clicking on '<span class="tagline_highlight">Create</span>' button your document will be created.<br /> And after you can add new instructions and subsections easily.</span></li> </ul> <div> <h2> Example of how to work a document </h2> <img alt="" src="../../html/images/diagram.jpg" width="738" height="172" /></div> </div> </div> <div class="clear"> </div> </div> </div> I need to validate the txtDocTitle since its a required field. How can i do this using jQuery. I cannot use Model validation coz this same model is used for other views also and it have properties from other tables. I need something to do with jQuery.

    Read the article

< Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >