asp.net-mvc

How to use ASP.NET MVC Html Helpers from a custom helper?

I have several pages listing search results, for each result I would like to display I want to create a custom View Helper in order to avoid duplicating the display code. How do I access the convenient existing view helpers from my custom view helper? I.e. in my custom view helper I would like to use Url.Action(), Html.ActionLink, etc. ...

In asp.net mvc, where do I put my strongly typed viewdata reference in my viewpage?

Hi, My viewpage doesn't have a codebehind, so how do I tell it to use a strongly typed viewdata? ...

Passing strongly typed viewdata to view page in asp.net-mvc

Hi, Do I have to manually pass my strongly typed viewdata to the call return View(); ? ie. MyViewData vd = new MyViewData(); vd.Blah = "asdf asdfsd"; return View(); It seems if I pass it as a parameter, I have to repeat the view name also? return View("index", vd); ...

Migrate to asp.net mvc control implementing IDataSource

Hi, Given the situation: A user control implementing IDataSource. It has a textbox or two, and a button. Now, when put on any page and adding a GridView with the DataSource being that control, presto you have a grid with filters . How should I go about implementing this scenario in asp.net MVC ? Any suggestions ? Should I give more...

how to simulate IsStartupScriptRegistered in ASP.NET MVC

hi, in Web Forms it was easy to register a script by this method, and to avoid duplicating a script you just use !IsStartupScriptRegistered() in and If statement. how can you do this in MVC ? thanks in advanced. ...

Create a url link with an ID for an action

Hi, In my view page, I want to link to the action "Display" and pass it the ID that the action expects as a parameter. Which html helper do I use? I don't want it to create the a href page of the string, just the url. ...

iText in Asp.net MVC

Hello, I want to use iText to write data to pdf. Assembles that I've added are iTextdotNET.dll Gnu.Classpath.Core.dll But the problem that I am facing is Error 1 The type 'java.io.OutputStream' is defined in an assembly that is not referenced. You must add a reference to assembly 'vjslib, Version=1.0.5000.0, Culture=neutral, Pu...

VB.NET Extension Method in View using ASP.NET MVC

I ran into a strange issue over the weekend while I was working on an asp.net mvc project in vb.net. I created an extension method to convert an integer to the corresponding month it is associated with. I tested the extension method in a console application so I know it is working. In my asp.net mvc project I have a view and want to...

Asp.net MVC and Entity Framework, Cannot access related tables

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SiteControl.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Website.SimpleRepository.Page>>" %> <asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server"> <h2>Page List</h2> <p> <%= Html.ActionLink("Create New", "Create") %> </p> <table> <tr...

ASP.NET MVC: HTTPContext and Dependency Injection

Hello, Currently I have an ActionFilter that gets the current users name from HttpContext and passes it into the action which uses it on a service method. eg: Service.DoSomething(userName); I now have a reason to do this not at the action level but the controller constructor level. Currently I'm using structure map to create contro...

Do your action providers have only string parameter types?

Hi, In asp.net mvc, should I make my parameters in my action methods string or can I have them as Integers? (say for page numbers) ...

VB Syntax to declare a single model in MVC (to leverage strongly typed views)

I'm trying to avoid the use of magic strings as much as I can, but I can't find the correct syntax for VB to bind a single model like is shown in this c# example. Can anyone point me in the right direction? (currently the below says "expected end of statement" under the Model text) <% Dim FormObject As Form = (Form)Model %> EDIT: A...

How to use TryUpdateModel in this context?

In my querystring I get a bunch of parameter names and values. As I understand I should be using the built in asp.net mvc function TryUpdateModel(modelInstance). It seems though that it is not working as I'm expecting. My parameter names do defer in capitalization. Is this a problem? Furthermore I have some custom types that need a speci...

How do I update only the properties of my models that have changed in MVC?

Howdy. I'm developing a webapp that allows the editing of records. There is a possibility that two users could be working on the same screen at a time and I want to minimise the damage done, if they both click save. If User1 requests the page and then makes changes to the Address, Telephone and Contact Details, but before he clicks Sav...

How to pass in ID with Html.BeginForm()?

In ASP.NET MVC I'm using the HTML helper Html.BeginForm("ActionName", "Controller", FormMetod.Post); But I need to post to: /controller/action/23434 How do I pass in the ID? ...

How can I have lowercase routes in ASP.NET MVC?

How can I have lowercase, plus underscore if possible, routes in ASP.NET MVC? So that I would have /dinners/details/2 call DinnersController.Details(2) and, if possible, /dinners/more_details/2 call DinnersController.MoreDetails(2)? All this while still using patterns like "{controller}/{action}/{id}". ...

How to return an XML string as an action result in MVC

I'm able to return JSON and partial views (html) as a valid ActionResult, but how would one return an XML string? ...

rails to .net mvc

I am planning a web site/store that needs to run on a windows machine. I have some experience in RoR but for this project I guess .NET is the solution. What is the learning curve like to go over to .NET MVC for an experienced programmer (RoR, Ruby, lots of C/++)? ...

How to write correct Regex for url's on the page without anchors?

Hi all, I want to cut all url's like (http://....) and replace them on anchors <a></a> but my requirement: Do not touch anchors and page definition(Doc type) like: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; So I need to find just plain text with url's... I'm tryin...

Supporting the "Expect: 100-continue" header with ASP.NET MVC

I'm implementing a REST API using ASP.NET MVC, and a little stumbling block has come up in the form of the Expect: 100-continue request header for requests with a post body. RFC 2616 states that: Upon receiving a request which includes an Expect request-header field with the "100-continue" expectation, an origin server M...