asp.net-mvc

asp.net mvc - MicrosoftMvcAjax.js throws javascript error when updating table elements in IE8

In IE8 or anything older, innerHTML is not supported on certain elements like TR & TD. Unfortunately, the MicrosoftMvcAjax.js file included in the MVC 2 project uses innerHTML for the Ajax update method within the Ajax.BeginForm or Ajax.ActionLink. To fix that, look into Line 18 of MicrosoftMvcAjax.js and replaced it with this: Sys.Mvc...

DataAnnotations [Required] Attribute doesn't cause Exception to be thrown

Hi I have an Asp.NET MVC application in which I use data annotations to add validation to some fields: [Required] [DisplayName("Course Name")] string Name { get; set; } However this doesn't seem to work as I expected. Basically If the page contains any other errors that I manually check for and throw a new RuleViolation()...

instant messaging notification

I want to build instant messaging notification on my ASP.NET MVC (C#) web aplication. Any example for that or some other way to learn how to do this? I want something like a facebook mailing system. ...

Get SessionId in jQuery Post

I am doing a jquery $.post('/Home/jQueryRateForumItem', but when I get to my controller the session id is always different on each post. I have tried; string g = HttpContext.Session.SessionID; string session = base.Session.SessionID; I'm pretty sure The session id shouldn't change but can't for the life of me think h...

Posted models (via jQuery) come back with all properties set to default

I fetch most of my data as models from my MVC app and just operate on them on the client side. When I'm done with whatever the user is doing I just post back the model/array of models to the server. In a specific scenario, I'm posting an array with two models in it back to the app. I can see all the values of the model in the HTTP...bu...

Basic View Model class reference question. (ASP.net MVC)

Newbie-ish questions ahead: Where should I put my View Model declarations? I created a file called "ViewModels.cs" in my Models folder. I created a few View Model classes, including one called RatingViewModel: using System; using System.Collections.Generic;var using System.Linq; using System.Web; namespace Web.Model { public class Vi...

MVC one view and different models

What is the better way to Get And Post different models with only one view. e.g I have a set of controls each control have its own model. I want to load them in one view according with conditions. And then on post i want to retrieve the values from this view. What is the better practice for that? ...

ASP.NET MVC Tracing Issues

Question How do I get ASP.NET MVC trace information to be consistent for in-page trace output as trace.axd? I may just be missing something obvious, please call it out if you see it. Background Info for Traditional ASP.NET So back in the regular ASP.NET days, you could simply add the following to your web.config: <system.diagnostics>...

ASP.NET MVC - 404 Problem

Hi! I have a view folder structure: Views Admin Post New and routing is defined with: routes.MapRoute( "Admin", // Route name "Admin/{controller}/{action}/{id}", // URL with parameters new { controller = "Admin", action = "Index", id = UrlParameter.Optional } ); But, for ...

how to create the custom authorize filter.

Hi Everyone, How do i create my own authorize filter for the asp.net mvc controller.I want to secure the controller actions that are releated to xo,what do i need to do for that. Thanks Sagar. Technology:Asp.net mvc ...

ajax update div

Controller action: public ActionResult Index() { ViewData["sample"] = DateTime.Now.ToLongTimeString(); Thread.Sleep(3000); return View(); } View page: <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Index</h2> <div id="divId"><%= Html.Encode(ViewData["sample...

ASP.NET MVC NerdDinner Tutorial question

Hi, I'm following Scott Guthries MVC tutorial (http://nerddinnerbook.s3.amazonaws.com/Part6.htm) and there's something I don't understand. The Controller class called DinnersController has the following Create methods: public ActionResult Create() { Dinner dinner = new Dinner() { EventDate = DateTim...

Can submit buttons in Ajax forms have their name attribute set?

i have the following form <form action="ManageLink" method="post"> <input name="artistName" type="text"/> <input name="songName" type="text"/> <input name="url" type="text"/> <input name="action" id="save" type="submit" value="Save"/> <input name="action" id="delete" type="submit" value="Delete"/> </form> with this...

Does MVC SiteMap 2.0 support custom attributes?

I'm using v2.0 of the MVC SiteMap project. With the System.Web.XmlSiteMapProvider in webforms, I often stored custom attributes on nodes, and accessed them through the Attributes[] collection. This is very useful for building non-standard collections of nodes, that all share an attribute. The MVC SiteMap doesn't seem to support custom...

View strongly-typed with ViewModel doesn't generate fields automatically

When I create a view and bind it directly to one class which has the properties I want to show on the view, the fields (textboxes, etc.) for it are created automatically. But when I create a ViewModel to encapsulate more than one object with data, this doesn't happen. Is there any way to get that working for a specific object which is in...

Suggestions for supporting multilingual routes in ASP.NET MVC

There were questions about multilingual apps in MVC here on SO but they were mostly answered by giving details about implementing Resource files and then referencing those Resource strings in Views or Controller. This works fine for me in conjunction with the detection of user's locale. What I want to do now is support localized routes....

ReSharper 5.0 choking on strong-typed view model that's located in same project

I'm using VS2010, ASP.NET MVC 2, and ReSharper 5.0. When I create a new view that's typed off of a model from the same project as my view, ReSharper doesn't see the reference to the model. This is the definition of my view: <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Web.Domain.UserViewModel>" %> Domain.UserViewModel ...

Strongly typed custom baseviewdata in a custom basecontroller

In my project I have strongly typed viewdata in the spirit of the following: AppleListViewData : ViewDataDictionary + SelectedTheme + ThemeList + SelectedApple + AppleList Where the first four are re-occuring accross all the viewdatas because they are used in the site.master To keep it DRY I elevated them into a BaseViewData c...

Difference between window.location.href and top.location.href

Can Anyone tell me the difference between window.location.href and top.location.href ???? And also where to use which one.. And which one will be better when redirecting after an ajax call in mvc??? ...

how to redirect to a url in mvc view

Hi, I am implementing live search and when the user selects any of the options then accordingly the page gets redirected depending on the option selected. I have jquery for implementing live search . In the select option :-->> I want to redirect my page to Index Function in the HomeControllers file using javascript. The Index function...