asp.net-mvc

Updating an MVC application Model along with data-source

Firstly, new to Asp.Net MVC and ADO.NET entity data model. While practicing an example, I created a table but forgot to set "Identity specification" to true for PK. Created a model for MVC Application using entity data Model and worked fine. Later on I've have set that "Identity specification" to true for that table in the DB. When I...

ASP.Net MVC how to determine if a user can access a URL?

So I was reading another question regarding login loop when you have a user logging in, set to return to a URL which they might not have access to after logging in (ie. an admin page, and the user logs in with a normal account). The solution under WebForms seems to be to utilize the UrlAuthorizationModule.CheckUrlAccessForPrincipal meth...

How tell when a hidden field is changed

I have some javascript I want to run when a hidden field is changed (via javascript) Is there any way to do this? (or anyway at all to have a field that is not "visible" in asp mvc that I can get a change event on) NOTE: I have confirmed that it is not the fact that the field that is hidden that is the problem, but the fact the field i...

How do we represent the following peice of view code in Spark view?

<% using (Html.BeginForm("AddToCart", "Cart")) { %> <%= Html.Hidden("ProductID", pr.ProductID) %> <%= Html.Hidden("returnUrl", ViewContext.HttpContext.Request.Url.PathAndQuery) %> <input type="submit" value="+ Add to cart" /> <% } %> Currently I am using # using (Html.BeginForm("AddToCart", "Cart")) { ${Html....

ASP.NET MVC: What if your model is just a Dictionary?

(I'm new to MVC). In my application I don't have a model in the sense of a class with properties. Oh no it's much simpler: my users basically fill in a bunch of string values for various keys setup elsewhere in the system (the keys are arbitrary and not known ahead of time, thus no pre-coded class)1. My "model" thus is just: Dictionar...

Why does this route not work correctly!?

I'm seriously going crazy with this. Here is what is in my Global.asax routes.MapRoute("BlogDetails", "Blogs/{id}/{title}", new { controller = "Blogs", action = "Details", id = "" }); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL wit...

FontFactory limitations, how do i get an underline or more font options

Hi I am declaring the following variables - which i use later in my code when writing out to PDF. When I drop down FontFactory intellisense though I get hardly any options, only TIMES and HELVETICA variations plus bold etc, how would I get Arial underline for example? Is their an additional using clause or something? Font font_small...

using Html.RenderPartial for the files in other Views/folders

How to use Html.RenderPartial for the PartialViews in other Folders? I have tried as: <% Html.RenderPartial("~/Views/User/Users.ascx", Model); %> It thrown an error: System.InvalidOperationException: The partial view '~/Views/User/Users.ascx' was not found. The following locations were searched: ~/Views/Main/~/Views/User/Users....

ASP.NET MVC how is best to use Antiforgery Token

I have a page where the user has his list of messages, he has the possibility to delete these messages. Erasing of the messages is done via ajax: $.post("/Message/Delete", { id: 1, antiforgery: 765764565454 }); How it would be more correct to do this: To have in page the antiforgery token and to add as parameter in each delete post ...

JQuery validation is not working for YUI editor. ASP.NET MVC

I'm using YUI(Yahoo UI) rich text editor control in my MVC view page. I need to do a jquery required field validation. It shows error message when submit without any value in that field but it stays after typing the value in the text editor. Please help me if anyone has tried it before or if you have any other javascript validation log...

This code doesn't seem to work in ASP.NET MVC2 ... what is it's equivalent, please?

Hi folks, i have this code which I doesn't seem to work in my copy of VS2010 B2 / VS2010 RC. var areaName = controllerContext.RouteData.GetAreaName(); (originally sourced from here). Now, it's dealing with Area's, so it's definately MVC 2 stuff. The error message is that the method GetAreaName() doesn't exist. Does anyone know the...

Get username in constructor for controller?

Hello I have a controller that gets data based on current user that is logged in. And I would like to assign a local variable like this: public UsergroupsCustAdminController() { User u = _us.GetUsers(HttpContext.User.Identity.Name).First(); this._customerID = u.CustomerID; } Somehow I cant get the value ...

Caching with variation by RouteValue

I have an Action that has diferent results depending on some route value. ie www.mysite.com/Home/About/Value1 is different then www.mysite.com/Home/About/Value2. Is there any chance I can use OutputCache on the action About in controller Home with diferent output for www.mysite.com/Home/About/Value1 and www.mysite.com/Home/About/Value2...

ASP.NET MVC + Javascript (calling c# code with javascript variables)

Hello, is it possible to call c# functions with javascript parameters (from javascript)? i.e. <script> function someFunction() { var data = "123"; var test ="<% AppHelper.GetSomething("+data+"); %>"; } </script> Thank You ! ...

ASP.NET MVC Deployment on IIS 6.0

Hi everybody, I'm just a beginner about ASP.NET MVC. Thought it doesn't have any problems in the developing time, I don't even know what to continue when I try to deploy. After deployment, I can only browse login page. I'm using Windows Server 2003 IIS 6.0 Visual Studio 2008 Is there any step by step guide that will be suit for beg...

Best way to do input validation when using Asp.Net Mvc 1.0, Json and jQuery Ajax

The title says it all really. I went through a few blogs/posts and there are some good solutions for input validations in Mvc 1.0, but most of them are about non-Ajax scenarios, so I was wondering what your preferred method is when using jQuery Ajax? Thanks. ...

How to implement Intuitive website URL using .NET plateform ?

Hi, I'm trying to implement a "restful" application using ASP .NET 3.5 but it seems that I need to use MVC .NET. Is that the only solution? For instance, I would like something like: /api/nab/(version)/(slug) I'll be happy to know how you manage to do that. ...

Getting data from ASP.NET Dundas control before Ajax.Submit in ASP.NET MVC

Hi, I am working on a project in ASP.NET MVC using C# 3.0. I am using the Dundas Chart Control for OLAP. As the Dundas control does not directly support MVC it is used on a standard ASP.NET page with a codebehind file. This page is displayed in an iFrame of a normal View returned from a Controller Action. I have a button in the iFrame...

ASP.Net MVC Passing multiple parameters to a view

In ASP.Net MVC I would like to render a different partial view depending on the renderview query string parameter. Therefore providing the facility for the user to choose to view products by thumbnail or by details. I have access to the chosen parameter in the controller but I do not know how to or, if I should be passing this to the v...

How to show Message box in MVC application

Can anyone please tell me about how to show message box in MVC application. I don't want to use System.Windows.Forms.MessageBox. Additionaly i want to catch the response of button click e.g. If we press OK we should get a value. As it is in the case of System.Windows.Forms.MessageBox. Is there any way? Thanks, Kaps ...