asp.net-mvc

Strongly typed ViewModel in POST action method contains only null values

Hi, I am trying to implement my Edit action methods with strongly typed view which receives a custom-shaped ViewModel class. In other words, I want a strongly typed ViewModel which contains the Linq entity that should be edited plus a few other objects that should be displayed in the View. I can see the view when calling the GET Edit ...

Do ASP.NET MVC helper methods like Html.DropDownList() encode the output HTML?

I am just wondering if I have to worry about encoding the values that get output when I use HTML helpers like Html.DropDownList(). If so, how do I encode them? It's easy to do if I were building the drop down manually -- just wrap each value with "Html.Encode()". However, I don't know how to do this when using HTML helpers. ...

How to get query string's value in a form post

I have an URL: /Account.aspx/Confirm/34a1418b-4ff3-4237-9c0b-9d0235909d76 and a form: <% using (Html.BeginForm()) { %> <fieldset> <p> <label for="password" class="instructions"> Contraseña:</label> <%= Html.Password("password") %> <%= Html.ValidationMessage("passwor...

How to send mail using IIS 5.1 in WinXP?

I have this code to send mail: public bool SendMail(MailMessage message) { message.From = new MailAddress(AppProperties.FromMailAddress, AppProperties.FromDisplayName); SmtpClient smtp = new SmtpClient { EnableSsl = AppProperties.EnableSsl }; try { smtp.Send(message); return true; } catch (Excepti...

Field max length in Entity framwork

I need to put a max length on my test field on my Views using ASP.NET MVC with the Entity Framework and I can't find how to get the max length of a varchar field. Is there an easy way to get that, or any other property of a database field thanks ...

Debugging ASP.NET MVC framework

What do I have to do in order to be able to step into ASP.NET MVC framework functions when debugging my own ASP.NET MVC application in Visual Studio 2008? I've currently installed the framework via the MSI installer. ...

Sharing tables/models across LINQ database model

I am not sure of the exact terminologies involved so please bear with me. I have an ASP.NET MVC website - my first go at using this - and I decided to spread the Database Model (dbml file in other words) across 2 logical mappings. I thought they were logical until I decided to include my "Tags" table in both of the dbml files. This now ...

Html.Encode does not return anything

Hi, I can't get this to work, I want to show a simple list of artist names but always get empty links back. foreach (Artist artist in Model) {%> <a href="gotosomewhere"><% Html.Encode(artist.Name); %></a> <%} I have debugged it, and I'm certain that Model contains a list of artists. Thanks, Peter ...

asp.net mvc: What are the advantages of Model Binding over manual assignments?

Aside from there being less code to write, what are the advantages? Is it more secure? public JsonResult Update (int id, string name) { Person person = new Person{ ID=id, Name=name } SavePerson(person); return Json(...); } OR public JsonResult Update (Person person) { SavePerson(person); return Json(...); } ...

Can't store XmlDocument in table column with data type 'xml'

I'm currently working on a small web application using Visual Studio 2008 Express. I'm attempting to retrieve an XML document from a server using a client library and then save the document into a database column (using Linq). The database column has the data type specified as xml. Unfortunately, I've been unsuccessful during my first fe...

Using Include and Exclude in asp.net mvc binding OR creat a new subset object?

Does it make sense create an object that contains only those properties that the user will input on the webpage, use that for binding in the controller, and then map to the full Entity Object? Or should you just use the entity object, and use Include and Exclude to make restrictions on what gets bound on input? ...

In MVC, what are the limitations on the Controller?

Should the Controller make direct assignments on the Model objects, or just tell the Model what needs to be done? ...

MSChart and ASP.NET MVC Partial View

I'm currently trying to add an MSChart to a partial view in ASP.NET MVC RTM. I have reviewed the following blog entry, and I'm currently investigating Option B. If I take my code an place it inside a View (ASPX) Page and it works fine, but when I copy the exact code into a Partial View (ASCX) I get the following excpetion: "CS1502: The...

MVC - Using Ajax to render partial view

Hi, I have this markup in an MVC app. <div id="ingredientlistdiv"> <% Recipe recipe = (Recipe)Model; %> <% Html.RenderPartial("IngredientsListControl", recipe.Ingredients); %> </div> <div id="ingrediententrydiv" align="left"> <% using (Ajax.BeginForm("Add Ingredient", "Recipes/UpdateStep2", new AjaxOptions { UpdateTargetId...

Load partial from class library

Is there a way to load partial views from a class library? I would like to pull out the common parts from several websites to make them easier to maintain. Currently I render my partials with (for example) <%Html.RenderPartial("~/Views/Search/_searchBlock.ascx", ViewData);%> This is file based, but when creating a class library, th...

Passing data from view to action ?? Solution ??

Hi friends, I'm trying to send the user id (integer) from a view to the action. If I pass it using routevalues object, the user id will be visible in the browser address bar. How can I pass user id from view to the action without using aforementioned method?? ...

How to use getJSON, sending data with post method?

I am using above method & it works well with one parameter in url e.g. Students/getstud/1 where controller/action/parameter format is applied. now I have an action in Students controller that accepts two patameters and return json object. so how do i post data with $.getJSON() using post method. Similar methods are also acceptable. ...

Relative AJAX path independent of application level on web server

I have some javacsript code looking something like below. Notice how it makes a ajax call to "/ContollerName/ActionName" with some parameters. This works fine as long as the application is deployed on a site root in IIS. But if I deploy it on a virtual directory the path will point all the way back to the site root and it will fail. $.g...

Prerequisite knowledge for ASP.NET MVC

After being frustrated in my attempts to learn the arcana that is ASP.NET, I decided to try ASP.NET MVC. I have extensive experience with C# 2.0 doing just about everything (WinForms, Windows Services, remoting, ...) except ASP.NET . I've been writing PHP for even longer than I've been coding .NET. With all of this experience, I thought...

tinymce and Jquery UI dialog working nicely

I'm having some problems with Jquery UI Dialog and TinyMCE. Passing data to a text area works well with UI Dialog and Jquery. So setting data in text area like this works fine: $("#MessageDialog #messageDto_Body").val(messagedata.Body); $("#MessageDialog").dialog("open"); When I attach a tinyMCE editor to the text area...