asp.net-mvc

Can I have form tag inside View in MVC?

Can we put form tag inside view in MVC. I need to keep report controller inside the form tag which is inside the view. It works fine. I am new to MVC, can anybody tell is it the correct way to work with. ...

LINQ to Entities pulling back entire table

In my application I'm pulling back a user's "feed". This contains all of that user's activities, events, friend requests from other users, etc. When I pull back the feed I'm calling various functions to filter the request along the way. var userFeed = GetFeed(db); // Query to pull back all data userFeed = FilterByUse...

How reliable is Verify() in Moq?

I'm only new to Unit Testing and ASP.NET MVC. I've been trying to get my head into both using Steve Sanderson's "Pro ASP.NET MVC Framework". In the book there is this piece of code: public class AdminController : Controller { ... [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(Product product, HttpPostedFileBase image) ...

Keeping values on form after submition

Hi, I'm trying to keep the entered data in the form after submitting by using "value=..." I'm getting a compilation error on the following code: <form id="myform"> <input id="hour" type="text" name="hour" value="<%=hour%>" style="width:30px; text-align:center;" /> : <input id="minute" type="text" name="minute" va...

Model state inferno - how can Model.A be two different things at the same time?

I have this <%=Model.StartDate%> <%=Html.Hidden("StartDate", Model.StartDate)%> it outputs: 2010-05-11 11:00:00 +01:00 <input type="hidden" value="2010-03-17 11:00:00 +01:00" name="StartDate" id="StartDate"> What the... It's a paging mechanism so the hidden value was valid on the first page and I've been able to move for...

Working with partial views

Hi. I'm trying to create a page that contains a grid and searching. The issue is that I want to have a partial view for the grid and one for the searching. If doing a search, this should render the grid partial view with the new information. At the moment I need information, such as what column I'm sorting by and so on, from the grid...

how to get all ListBox items on submit action

how I get ALL ListBox values (not only selected items) on submit action in asp.net mvc2 project. I'm using Ajax forms like Ajax.BeginForm("actionname", new....) I already try to select all items on OnBegin event of Ajax options but still I havent got all ListBox items have any idea ? thanks ...

asp.net mvc Ajax.BeginForm

Hello, I'm having some difficulties with Ajax.BeginForm I have something like this in a view <% using (Ajax.BeginForm("ActionName", null , null, new { id = "FormName" })) {%> <input type="hidden" value = '<%= Html.Encode( Model.id) %>' name="id"/> <textarea id="message" name=message rows="4" style="width: 90%"> ...

How to convert Subsonic MVC 1.0 to MVC 2.0 final?

Here is the subsonic asp.net mvc application http://subsonicproject.com/docs/MVC_Starter_Template but its for MVC 1.0. How can i convert it to MVC 2.0? ...

Model binding HttpPostedFileBase and then storing the file to datastore

ASP.NET MVC seems to correctly automatically bind between HTML form's file input field and HttpPostedFileBase. On the other hand it cannot bind from file input field to byte array..I tried and it issues exception - something about not being able to convert to Base64. I had only the byte array property on my Model classes previously becau...

How to form submit and show a different page in ASP.Net MVC?

hi guys i'm new to asp.net mvc.. so basically i just build up a two page app which takes the registration information of the user and post it to the database. i use a lot of jquery and ajax calls to retrieve data from the database using linq to sql stored proc object. and currently i'm stuck at one page where after the user submits t...

SDK jar file downloading taking time in production

Hi All, I am having a strange issue, In our ASP.NET MVC application we are using jar files (Applet) , which will get downloaded in one of the first pages, In the QA environment these jar files were downloading with no time but in the production envirnment its these jars are taking more than a minute. I don't have much knowledge on the ...

ASP.NET MVC : AJAX ActionLink - Persist Data

Hi guys, I'm really new at this and I was searching the web for an answer to my question and I couldn't find it, so here I am posting my question :) I'm trying to create a new record in my table Facility. For my goreign keys I'm displaying the choices in tables instead of a dropdowns. When the user clicks on the select link which is an...

What would be the best way to dynamically add a set of rows to a table using JQuery?

I have a following table using MVC that shows number of items the user has. <table border = "1" id="tblItems"> <% var itemnum = 1; foreach (var item in Model.Items) {%> <tr> <td colspan="2" bgcolor="Silver"><strong>Item#<%=itemnum%></strong></t...

MVC 2, IoC, ModelView, and Binding ...

If you can register your Controllers in your IoC implementation then why can't you also have your ModelViews created from your IoC container? I'm currently using Autofac 1.4 for IoC injection for the controllers with the following: ControllerBuilder.Current.SetControllerFactory((IControllerFactory) new AutofacControllerFactory(Contain...

How to create a route that catch all pdf file?

I want to have my pdf files sent this way to my users : public ActionResult GetPDF( string filename ) { return File( filename, "application/pdf", Server.HtmlEncode( filename ) ); } But I don't know how to create a route that will catch all the different pdf file in my site? Thanks a lot for the help! ...

MVC noob - changing part of URL in a link

Hi, I have a site that supports localization. I would like to be able to switch between english and french. Let say the user is currently at URL: http://www.mysite.com/en/Home I would like to redirect to: http://www.mysite.com/fr/Home If the user click on a "French" link how to change the URL part to "fr" yet not change the "Home" pa...

jQuery 1.4.2 JSON format breaking what used to work in 1.3.2

I just upgraded my jQuery from 1.3.2 to 1.4.2, and I think it's giving me some issues. I have a $.post() function that calls a controller method and passes along some data that I format like so: $.post(url, { arrayParam: myArray, param2: false }, someCallback, 'html'); In Firebug, the POST says the parameters in 1.3.2 look like this: ...

ASP.NET MVC Futures 2 and MVCContrib 2 in the same web app / project

I have referenced both Microsoft.Web.Mvc.dll (MVC Futures 2) and MVCContrib.dll (from MVC Contrib 2), both current releases from Codeplex and I have a problem with strongly-typed RedirecToAction<>() function of Controller. It worked fine until I referenced Futures 2.. This is the compile time error. Apparently this function is implemen...

How do you pass a JSON object to an MVC action parameters?

I would like to pass {"id":1, "name":"stackoverflow", "parameter2":false, "parameter3":true} To my action public JsonResult Action(int id, string name, bool parameter2, bool parameter3) { //... } Using JQueries ajax method using the JSON as the data parameter $.ajax({ url: "target.aspx", data: {"id":1, "name":"stackover...