asp.net-mvc-2

Creating a div element on the server side using C#

I am trying to create divs dynamically in a view page of an asp.net mvc project. This is the pseudo code: <% foreach (element in Model) { create the html div element with Div.id = Model.id } %> I looked in the system.web.mvc.htmlhelper object. It provides support for a lot of html elements but n...

How do you find out the URL of HTTP POST request in the ActionResult

Very simple question but I am unable to find an answer, I have a MVC 2 app in C# I have a ActionResult the accept's HTTP POST's How do I find out the URl of any posts to my ActionResult. Thanks, ...

Annotation for Json Model in ASP.Net MVC

Hi, I'm working on an ASP.Net MVC2 application and use the jsTree-Komponent for jQuery to render a tree with checkboxes. To select specific nodes in a convenient way my JSON has to offer a "class" attribute. Here's an example how jsTree wants to consume the JSON result: [{"data":"Root1","attr":{"id":"10","class" : "jstree-checked"} .....

MVC2 and session

I'm making use of a captcha generator. http://xcaptcha.codeplex.com/. In the example it shows using Session.Add for comparing captcha generated vs answer. I wanted to make this a part of my model's rule violation checker but I can't seem to find/work with the correct parts of session there. Am I missing the way to navigate to session fro...

Image position changes when IP address is typed in the address instead of hostname

I have a web site in ASP.NET MVC 2. I deployed it in the server. But when I browse the site, the image position behaves differently with ip address and host name on the URL. http://mysite/applicationsite http://192.28.252.13/applicationsite I couldn't figure out why its behaving differently. The image is more to the left when used ip ...

Useful Silverlight class library with reference to .NET class library.

I'd like to develope simple set of controls to display many sort of data and be useful in normal silverlight application and can be used in ASP.NET MVC2 application. Right now i have no idea how to link those tehnologies, but this isn't my concern right now - i just heard it is possible and i'll find out how to do that... Right now i'd ...

Problem with multiple ASP.net MVC2 applications on IIS7 ( hosting an MVC app. in another MVC app. )

Hi, what i am trying is the following: I got an MVC app. running DIRECTLY in "Default Web Site"... I got another app. ( ProductionService ) which is anotehr standalone app.. Looks like this in IIS-Manager: My problem is, that a requets to "ProductionService" is not routed to the app., but instead is handled by the MVC-app. runnin...

How to update entity objects without deleting ?

I have an entity generated from my database that contains one table. When i make changes in the DB i obviously would like these changes to reflected in my model. My current approach is to delete the item from the designer and then right-click - update model from database. This works for me at the moment. Is there a different approach t...

How can I pass FORM on a button click in MVC2.0?

I am calling a controller method SendMe(formCollection myForm){}. But I don't know how to pass Form that contains some information. I know how to read it, and also, how to call SendMe() on given controller, but I don't know how to pass it. Though, for the reference I am calling SendMe as: <div id="menucontainer"> <ul id="me...

ASP.net MVC 2 how do I handle A potentially dangerous Request.Form value was detected from the client

I have been browsing the web and stackoverflow trying to figure out how to handle this error. A potentially dangerous Request.Form value was detected from the client The error occurs when a user enters in html or xml tags( < p> or < HeyImXML>) and tries to submit a form. The input is not suppose to contain any sort of markup at ...

In ASP.NET MVC 2 / EF, comma in number causes model binding error

In my HTTP POST controller method for add/editing data, I'm receiving an entity from my EF data model. Some of the fields in that entity are of type double. Everything works fine unless the user types in a comma for a thousands separator, which then causes a model binding validation error. Has anyone run into this before? Is replacin...

ASP.NET MVC 2 Data Annotation Validation -- StringLength Minimum not working on client-side

Hi. On one of my models I have a property annotated with: [StringLength(60, ErrorMessage="Title must be between 60 and 10 characters", MinimumLength=10)] When the form posts to the server, if it's under 10 characters, then validation fails as it should do. However, on the client-side, it only checks that it's under 60 characters -- n...

WebRequest and WebService call asynchronously in C#

I have MVC application (applies to non MVC as well) where a user is posting in data. I need to take this data, send it off to two seperate end points (one using a WebRequest form POST and one using a Web Service), parse the result, and send the result back to the original user. The issue at hand is that both end points take about 20-30...

How do I implement a "registration confirmation" in ASP.NET MVC?

I'm an absolute beginner with ASP.NET MVC and I'm trying to build a pretty simple application, but I'm having a hard time getting out of the webforms thinking. I need to register users so they can download my application. I need to capture their information in three screens. Rather than write the database from each view, I want to aggre...

Can you have Child Editors in ASP.Net MVC 2?

I have an editor template for a custom object. Pretty basic - just has a bunch of strings and dates: <%:Html.LabelFor(model => model.AString)%> <%:Html.TextBoxFor(model => model.AString)%> <%:Html.LabelFor(model => model.ADate)%> <%:Html.EditorFor(model => model.ADate)%> <%:Html.LabelFor(model => model.AnotherDate)%> <%:String.Format...

Ajax call not working in mozilla

My code is working fine in all the browser except mozilla firefox $(document).ready(function () { var id1 = '<%=ViewData["UserName"]%>'; var id2 = '<%=ViewData["UsrProfile"]%>'; var msg = $('#addFrnd').attr('value'); $.ajax( { type: "POST", ...

mvc.net routing: routevalues in maproutes

Hello everyone, i need urls like /controller/verb/noun/id and my action methods would be verb+noun. for example i want /home/edit/team/3 to hit the action method public ActionResult editteam(int id){} i have following route in my global.asax file. routes.MapRoute( "test", "{controller}.mvc/{verb}/{noun}/...

ASP.NET MVC2 Empty Project Not Loading

My environment consists of Visual Studio 2010 and Windows 7 a few months ago I developed an MVC2 application with no problems however after trying to create a new project recently I received the error below. I did find the link http://support.microsoft.com/kb/894670 but this is not relevant because I am not using IIS for testing, just F...

How to use a ShortDate string format with Html.TextBoxFor

Using Entity Framework with MVC2, I have a series of date textboxes, that I want to display data from the model in a short date format, but I have to use Html.TextBoxFor in order for the update code to work (Having tried using HTML.Textbox the data never gets saved to the model). <%: Html.TextBoxFor(model => model.Item.Date, String.For...

Is it applicable to place methods inside ASP.NET MVC views?

The current code of one of the views in my project is a large, monolithic one and I just want to organize it. Is it just fine to place methods inside my ASP.NET MVC view? ...