asp.net-mvc

ASP.NET MVC - Html.DropDownList

I would like to display a textbox depending on the value selected in the Html.DropDownList. Is this possible? ...

Maintain the querystring in all pages in mvc

I need to maintain the querystring in all pages in my asp.net mvc(C#) application. For ex.: I will call a page www.example.com?Preview=True. The querystring should be maintained whatever the page i click in www.example.com. i.e. When i click About us page in www.example.com, the url should be www.example.com/AboutUs?Preview=True How c...

ASP.NET MVC action methods

Possible Duplicate: How do you RedirectToAction using POST instead of GET? I have two versions of Index action in my controller, one for GET and another for POST. How can I use RedirectToAction method so that POST version of Index action is called? Normal RedirectToAction("Index") calls the GET version. ...

Asp.Net WriteSubsitution vs PartialView - the right way

Hi, I have a partial view that should not be cached in a output cached MVC view. Usually you write non-cached content by using Response.WriteSubstitution. The problem is that WriteSubstitution takes as a parameter a HttpResponseSubstitutionCallback callback which looks like this: public delegate string HttpResponseSubstitutionCallback(...

c# mvc dynamically create controller from string name - eval?

Hi, I'd like to create a new instance of a controller, via a string name. In classic ASP I'd do an eval, but how to do it in c#? eg: If I wanted to create an instance of the "AccountController, normally I'd write: var Acc = new AccountController(); Now if the controller name is only available as a string, how could I instantiate t...

Where does this permanent SQLExpress connectionstring come from (not web.config)?

Today I noticed that in my ConfigurationManager.ConnectionStrings the very first instance is .\SQLEXPRESS. I remembered explicitly removing this entry from my web.config so I checked again, but didn't find a thing. Then I did a search over my entire solution, not a single match. Where the hell is this connection string coming from and ho...

Strongly typed views in NHaml?

I have a strongly typed view and want to use it in an NHaml page. With the WebForms engine I would describe the ViewData type in the <%@ Page%> directive or in the codebehind file. How would I go about that in NHaml? ...

Global ASAX - get the server name

Hi, Can anybody tell me if there is a way for me to get the domain name of my site in the Application_Start event in the global.asax? Normally I'd just get it from Context.Request.ServerVariables["SERVER_NAME"], but this is not available. I'd ideally also like to get the URL from the request that kicked off the application. Hmm - fro...

Add a .asmx file to asp.net MVC?

Is it possible to add a .asmx file to an MVC project and have .asmx code call the controller and have the controller return data to the .asmx code? ...

Application pool reset breaks ASP site

I am seeing a weird behavior on IIS7 on Windows 2008. I have an ASP MVC application installed and fully functioning. Every time i reset its application pool, the website stops working and displays a 404 error. The only workaround I found for this is: 1. Rename default.aspx, global.aspx, and web.config to something else 2. Create a simpl...

ModelState.IsValid == false, why?

where can i see the list of errors of which make the modelstate invalid, i didn't saw any errors property on the modelstate object ...

How can I use multiple projects to separate a large ASP.NET MVC site into departments?

Suppose I have a very large site like amazon.com. I’d like to use asp.net mvc for the whole site but having one large project with hundreds of contributors is not practical. I’d like to split the work into projects like books, tools, toys, groceries, etc. for each department. Then when they build and deliver a new release I can just d...

Newbie MVC Routing

I'm clearly missing the concept of routing - for an experiment I've set the route as routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute("Standard", "{devicetype}/{devicesub}/{language}/{culture}/{controller}/{action}/{id}", new { ...

How do you reset form values in asp.net mvc?

Due to crazyness in this project (Too long a story to get in right now), we need to keep the data in the Model of the form, but not display it on the form on successfull postback, where the form postback was succesfull - <%= Html.TextBox("FullName", "", new { @class = "required", title = "Full Name is required" })%> Dosent seem to do...

Should controller lifestyle always be transient in Windsor configuration for ASP.NET MVC?

I ran into a problem where I had an Html.DropDownList in my view that would postback the selected value the first time I submitted the form, but each subsequent postback would only post data from the initial postback. So I added lifestyle="transient" to the component element where I had configured my controller for castle windsor, which ...

download actionresult via jquery

Hi All, I am trying to call a File ActionResult via jQuery $.get("/Home/DownloadAction") and I can see that the method is being called but no prompt to download the file (no errors either)? Can someone please explain? Because if I make it Html.ActionLink("Download", "DownloadAction") it works as expected. Thanks, rodchar ...

Use Asp.net MVC1 or MVC 2?

A project is due to be started and finished by the end of the year. It's for internal company use, will be entirely done by a single developer(me). I intend to make use of data annotations(via Stephen Walther) and xVal for the first time. It's a 2-3 page web app to collect defect information. It was started in asp.net without a master p...

How do I inject plain text into an asp.net MVC1 master page from a child?

All the searches I've come up with talk about regular asp.net where there is a code behind page or you are accessing an asp.net control of some sort. Since there is no code behind in the master page for Asp.net MVC how would I put a sub page name in plain text/html just under the master page title? <div id="header"> <div id=...

Does ASP.NET MVC ViewPage or ViewUserControl allow multiple inheritence

I have one Viewpage where I inherit List version of my model class to show a list of products. Now on the same page I want to create a form for which I need to use my model class properties. As I'm using a List version of model class, I'm not being able to get the properties without iterating the items in Model. I tried creating an UserC...

ASP.NET MVC render View and retain values when validation fails on a dynamically generated View

I'm trying to build a dynamically generated view. My controller class for Create action looks like this public ActionResult Create() { List<FormMetadata> formItems = GetFormItems(); return View(formItems); } and the View so far is something like this <% using (Html.BeginForm()) {%> <table> <% foreach (var ...