asp.net-mvc-2

T4MVC appears to be losing code it has already generated

I'm having a problem with T4MVC losing the code it generated each time I do an SVN update. I can fix it by deleting the .generated.cs files and re-running the template. But this is proving a bit tiresome. Is there something I am missing? First a little background information ... I am using C# v4, VS2010 and ASP.NET MVC2. I use subver...

My application works perfectly local but not in the remote server

When I upload the files on the remote server I get the following message: Object reference not set to an instance of an object And a few errors supposed to be happening in the ClassDesigner file and other few classes... I need help urgently please. What do you think is going on? Thank you! ...

increment label

I have a button that adds a new row to the view with the following code. Is there a way to increment the label? What I would like is to say "Name 1:" "Name 2:" for every row. string s = "<table>\r\n"; s += " <tr>\r\n"; s += " <td>\r\n"; s += " <label>Name: </label>"; s += " <input></input>"; s += " </td>\r\n"; s +...

type submit vs type button

I have a button which right now is set as a type "submit". This calls the controller, execute some code and returns back to the view. When I use jquery to hide the button, I see that when I click on the button, what I have hides the button but as soon as the view is returned, the button is not hidden no more. Whereas with type "button", ...

ASP MVC 2 Files

In controller, i create file. and invoke it by jquery.post. i understand that return file to view is impossible because of ajax. so i create file on disk, and return url of file to user. i think its not best way, but. my probleb now, is to know when user downloaded file, and delete it, how can i do it? or any others good ways to handle? ...

Viewmodel to allow sorting and filtering for mvc contrib grid

In my attempt to enable sorting and filtering in conjunction with the MVC contrib. grid I have decided to use a Viewmodel which contains the grid data plus the sorting and filtering information. I added a form under the grid and the Viewmodel is used to maintain the state of the form and to carry the data for the grid: public class Gri...

ASP.NET MVC 2 Parameter Array

Hi, I need to have the following routing logic: http://mydomain.com/myAction/{root}/{child1}/{child2}/... I don't know what is the depth of the route so I want the action's signature to look something like that: public ActionResult myAction(string[] hierarchy) { ... } Have no idea how to write that route. Help? Thanks a lot...

ASP.NET MVC2 : DateTime modelbinding via HTTP GET

I'm getting some trouble binding a date from QueryString : I have the following model public class QueryParms { public DateTime Date { get; set; } } And the following controller action : public ActionResult Search( QueryParms query ); I have a form, with a field where I can type my date. If the form is FormMethod.Post, everyt...

hidden form element problem - asp.net mvc

Hi, I create a strongly typed form like this in my controller: return View("BlaForm", Bla); In the view I use something like this: (1) <%= Model.Version %> (2) <%= Html.Hidden("Version", Model.Version)%> Here (1) is just for debugging purposes. After a successive update of my object this produces something like this: (1) ...

Cascading dropdown

Is there any alternative to json data to cascade dropdowns? I am using country and state dropdown but cascading the data with json take too much time [HttpGet] public ActionResult States(int countryId) { DateTangoEntities _db = new DateTangoEntities(); var tset = _db.States.Where(r => r.CountryID == countryId).Select(r => ...

Creating a graphical breadcrumb or process trail in .NET MVC 2

I have a breadcrumb structure similar to the image above. It displays the progress trail of the forms, the form names and the current page being displayed and it also gives the user a guide to the start and end of the process. This was originally put together in classic ASP. What would be the best approach to recreating this in MVC 2 ...

How to accept JSON into MVC2 action method as parameter and have it deserialize automatically?

Background: I have a MVC2 project and am using jQuery 1.4.2. I have a .NET class that I put into a view using a JsonResult. The page then uses jQuery to do stuff which will result in properties of the object put on the page by item (2) above. When a certain page element is clicked jQuery $.post's the JSON.stringify(myObj) back to actio...

Form Validation Messages in ASP.NET MVC2 - using images instead of text for error messages

OK - at the moment, to validate my pages I am using [Required] in my model in an MVC2 C# project. For eg in my model I have: [DisplayName("Username")] [Required(ErrorMessage = "Please enter a Username")] public string UserName { get; set; } ... and in my view I have <%=Html.ValidationMessageFor(x => x.UserName, "*")%> But then th...

View rendering problem

Hi guys, In my application I have two Master pages and they are used in various different cases. Say one master view just renders the top half of the page and another master view that renders the top half plus a navigation bar to the side. We pass around data to these Master pages using view models Now in my controller my index action ...

hide submit button

How do I hide a "submit" type button on server side in asp.net mvc2 using c#? ...

RequireHttps attribute redirecting to wrong port

I'd like to stick with the attribute as it is simple. Apparently VS2010 development server supports HTTPS as it worked without problem which was nice. I followed the login link, was redirected to 443 and presented with a cert. I entered my credentials and submitted. Then I was redirected to standard port 80 instead of the static port I...

ASP.Net MVC background threads for email creation and sending

I'm looking at postmarkapp.com to handle the sending of email from my asp.net mvc 2 application using the .net library that they provide: postmark-dotnet library In their documentation they mention that sending emails w/ attachments can take some time and its better to do this in a background job. For my application I could be sending ...

Why did they use this C# syntax to create a list of links in ASP.NET MVC 2?

I'm having hard time understanding the following C# code. This code was taken from Pro ASP.NET MVC 2 Framework by Steven Sanderson. The code esentially creates URLs based on a list of categories. Here's the code: Func<string, NavLink> makeLink = categoryName => new NavLink { Text = categoryName ?? "Home", ...

Will configuring AppFabric to be my ASP.NET Session State Provider also make it the provider for MVC2 TempData?

I am setting up AppFabric to be the Session State Provider for a website we are building in Asp.Net MVC2. Since TempData is stored in the session will doing this also make AppFabric the storage provider for TempData? ...

What's wrong with these asp.net mvc routing rules?

I have defined a series of Routes in Global.asax.cs: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute(null, "", // Only matches the empty URL (i.e. ~/) new { cont...