i've been playing with MVC for a while now, but since the project i'm on is starting to get wind in its sails more and more people are added to it. Since i'm in charge of hacking around to find out some "best practice", i'm especially wary about the possible misuses of javascript and would like to find out what would be the best way to h...
We have two websites that share some business processes and UI elements. Lets focus on a contrived example: we have an apartment rental site and a boat exchange.
For instance, on our apartment rental website, we may want to let users bid to buy boats. On our boat website, we may want to let users search for apartments.
An obvious s...
Hi. I have a website that was developed using ASP.Net MVC and uses Log4net for exception logging. The website was running fine until about 4 hours ago. We haven't made any changes to the website in the last 2 weeks. The website has been running smoothly since we put it up about 1 month ago. The website is hosted at our ISP on a Shared Ho...
Hi,
The question is how to create controls/partial views/edittemplates (ascx files) in ASP.Net MVC2 so that they are "self-containing". Self-containing means here that if some Javascript code should be applied on the control, that's not included in the page (aspx), but in the control itself.
Specific example:
NerdDinner's DateTime.ascx....
I have an ASP.NET MVC2 application, and I'm using FormsAuthentication to manage the Auth Cookie. When the cookie expires and the page is access, I need to display the Username in the field and the Remember Me checked. How can I do this once the cookie expired and I don't have access to it?
...
As my application initializes, I want to create a registry of any MVC action whose method has a certain CustomAttribute on it. I want this registry to keep track of the MVC Area, Controller, and Action. I could require the person adding the attribute to specify this information, but it seems like I should be able to figure out this infor...
I have a partial view that renders a list of objects into a table format and allows editing of the values...
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<whoozit.Models.PictureModel>>" %>
<% foreach (whoozit.Models.PictureModel p in Model)
{ %>
<td>
<%: Html.TextBox("name",p.name) %>
<%: Ht...
My application sends out some emails, and the image paths referenced in the e-mails need to vary depending on how the user accessed the page that is sending the email. I've used variations of the code before many times with no problem, but this is the first time I'm trying to do it in an MVC app:
var relImagePath = controllerContext.Htt...
What is the best way to delete an item in MVC? I have a list of items. Each row will contain a "Delete" link. I want the Delete link to prompt for confirmation, then delete the item from the datastore and refresh the page with the new data.
Here is my view code:
<%: Ajax.ActionLink(
"Delete"
...
Given the following model which has a name, url, and an arbitrary list of keywords (I want the user to add a series of keywords) ...
public class Picture
{
public Picture()
{
keywords = new List<string>();
}
public string name {get;set:}
public string url {get;set;}
public List<string> keywords{get;set;}
}
... and the ...
I'm a bit new to ASP .NET MVC and I'm having trouble understanding the need for ViewModels, and what makes them different from regular Models. Any good resources on the topic ?
...
When running my web app on my local machine i can ref css/scripts/images using:
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
But when I deployed to my Development server, it wasn't able to find any of my content. After researching the issue everyone suggests using the below method:
<link href="<%=Url.Content("~/...
I'm trying to add a search box to a master page in an ASP.Net MVC web app. What's confusing me is how to properly implement it in the master page. So the user types in data into this search box, how should the data be handled from an MVC perspective?? I know I could use he master page's code behind, but I shouldn't. I'm currently try...
I am trying to abstract out the route registraion process out of global.asax into a bootstrapper. My class looks like:
public class RegisterRoutes : IBootstrapperTask
{
private readonly RouteCollection routes;
public RegisterRoutes(RouteCollection routes)
{
this.routes = routes;
}
public RegisterRoutes() : ...
Hi,
In a model of my ASP.NET MVC application I would like validate a textbox as required only if a specific checkbox is checked.
Something like
public bool retired {get, set};
[RequiredIf("retired",true)]
public string retirementAge {get, set};
How can I do that?
Thank you.
...
I've download SharpArchApplicationTemplate_1_6_VS2010.zip
I have read through this:
http://wiki.sharparchitecture.net/VSTemplatesAndCodeGen.ashx
However, this is aimed at VS 2008
I'm using 2010, and I can't see how to install the template(s)?
Have I downloaded the wrong thing?
I can't see anything on the wiki relating to 1.6 installa...
I have the following nested viewmodel class...
public class CustomerModel
{
public string name;
public Address mailingAddress;
public Address billingAddress;
}
public class Address
{
public string line1;
public string city;
public string country;
}
I was hoping that there is some automated way to create an edit page, but ...
What is the difference between <% %> and <%: %> in context of asp.net MVC view engine. In the MVC2 book it's given as follows:
<% %> code nuggets execute code when the View template renders.
<%: %> code nuggets execute the code contained within them and then render the result to the output stream of the template.
When to use the firs...
I'm trying to inject a dependency to my MVC controllers like this
private static void RegisterContainer(IUnityContainer container)
{
container
.RegisterType<IUserService, UserService>()
.RegisterType<IFacebookService, FacebookService>();
}
The UserService class has a constructor like this...
public Use...
OK, I've bound an asp:Treeview control to a sitemap datasource, but I can't figure out any of the options ... All I want it to do is:
Load "closed" - that is with all nodes collapsed
close all other nodes when a new one is opened
Stay open the way it was on the previous page
Give me the option of changing the open/closed/empty images...