asp.net-mvc

Render View programmatically into a string

I would like to get the html code a view would generate in a string, modify it in my controller, then add it to my JsonResult. I found code that would do what i'm talking about from a partial. I would like to do it from an aspx View though. -- Extra explanation: Let's say I have a page Frame.aspx that /Controller/Frame will return I ...

In asp.net mvc How do i use htmlDropdownlist with selected value and onchange event?

How do i load the dropdown list with a selected value there is a also an onchange event? List<SelectListItem> environments = new List<SelectListItem>(); environments.Add(new SelectListItem { Text = "Development", Value = "DEV"}); environments.Add(new SelectListItem { Text = "Staging", Value = "STA" }); environments.Add(new SelectListIt...

Check ASP.NET MVC values (roles) from client (jQuery)

I have an MVC app that is basically one page with a bunch of AJAX calls that parse returned JSON and then using jQuery will populate the page. So, for example, if I call /API/Users/List it will return some JSON and then I'll parse that and dynamically create an li element for each user. Then, I put an edit link next to each user name a...

Will this Post/Tag DB schema cause problems later?

I'm planning a new service for my ASP.NET MVC app and want to use tags. I've never really been too fond of tags, but SO delivers so I'll give it a shot. Here's the simplified schema I'm thinking about: Post Table ------------------ PK PostId BigInt (or perhaps uniqueidentifier) ...more post related fields... Tags nvarchar(200) Then I...

Stack trace error

I am having the error message:I can`t figure out what is wrong. Can someone help me please. Thanks. Stack Trace: [NotSupportedException: Collection is read-only.] System.SZArrayHelper.Clear() +56 System.Web.Mvc.CollectionHelpers.ReplaceCollectionImpl(ICollection`1 collection, IEnumerable newContents) +125 ...

Wanting to mix server side ASP.Net MVC expansion in javascript file, but how... RenderPartial?

Hi, I have some common javascript functionality that I want to share across several views/pages. However I want to put some C#/ASP.net into the javascript - pulling in some data from the server. It seems like the best option is to use a partial page, and include the javascript in that. Just wondering if there is a javascript equivale...

Problem with Primary Key in a Partial View shared by Create and Edit views.

I have a partial view (user control) that is shared by my Create and Edit views. When I use it in the Edit view, I have to to include an hidden field (Html.HiddenFor) to prevent a 'Row changed or not found' error in my data service, but when I use it in the Create view, I have to remove the PK hidden field, to prevent an error over tryi...

How to start a new ASP.NET MVC site?

Hi, I'm a experienced .NET developer, but I havent done much webdevelopment and particularly not a new site from scratch. Now am I thinking of building a site for one of my hobbies. I realize that much of the functionality I need has already been bulit and hopefully released as opensource. My wish is to find a skelletton for my site wi...

Nlog logging to database in n-tier environment

We are currently using nLog for logging (which was an arbitrary choice made some months ago so it can be changed if necessary). nLog can log to a database but requires a ConnectionString. This is an issue for us as we are in an n-tier environment and we have no database access at the Presentation tier (everything goes back to WCF hoste...

jQuery UI DatePicker image not showing.

I have the following init code for the datepicker, but the default 'Choose Date' link is displayed, not the image. This is in an MVC project, but that shouldn't affect anything to the best of my knowledge. $(function () { $(".date-picker").datePicker({ showOn: 'both', dateFormat: 'dd-mm-yy', ...

How can I determine the current controller action in an mvc sitemap?

Hi all, I'm stuck with a problem of which I can not imagine I am the first person having to deal with it. Yet, Google comes up with nothing useful and neither does SO, so here I am. I'm using ASP.NET MVC1 with a sitemap. Using an html helper I create a navigation menu that highlights the current selected option in the Site.Master page....

Building a repeatable HTTP request parameter

What I am facing: I am building a search application that involves several search parameters and I would like to be able to bookmark the URL for later usage. I imagine the solution would something like the following: User views the page, picks search parameters they want to filter. Browser do a POST request with the parameters. The a...

"ASP.NET Webforms MVP" as an alternative to "ASP.NET MVC"

Some days ago I discovered a "thing" which is called the ASP.NET MVP framework ( http://webformsmvp.com/ ) What do you think of that ? Is it worth to take a look on it ? Has anybody already experiences with that ? I come from the "webform side" (and also from the desktop development) and really don't want to move to ASP.NET MVC for th...

switch from asp.net mvc 1.0 -> 2.0 - s#arp framework

Hi, I have an older asp.net mvc solution (s#arp framework) whith two projects one for web and one for controller. I have changed the dll to the latest versions (2.0) for System.Web.MVC and Microsoft.Web.MVC. I have also adjusted my Web.Config: <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364...

pass multiple values present in ListBoxFor to controller, while postback

I am using asp.net mvc 2.0 in my application and the application requires to get multiple values from a ListBox, from view to controller. The scenerio is like that, I have two listbox say ListBox1 and ListBox2 and on the load of a page, I initally load Listbox1 with some data. Now a user can transfer some of the data from one Listbox1 ...

Asp.net Mvc Routing problem

Hi all; Global.asax Code: routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "article", action = "article", id = UrlParameter.Optional } // Parameter defaults ); I want to use url routing like this: www.domainname.com/Article/123/bla_article how can ı do this ? Thi...

MVC Validation Not Working In Web Forms Project

Hi, I have the following code in my aspx view page: <% using (Html.BeginForm()) { %> <div> CustomerCode:&nbsp; <%= Html.TextBoxFor(x=> x.CustomerCode) %> <%= Html.ValidationMessageFor(x => x.CustomerCode)%> and this code in my model: public class MyModel { [Required(ErrorMessage="customer code req")] [Stri...

How to dynamically determine which HTML 'wrapper' file to use based on the Action Method being executed?

We have an MVC app that injects our content into a HTML wrapper which supplied by the client. There are multiple wrappers, such as fund.html, share.html, factsheet.html, and home.html The wrapper is stored on our webserver. We need to load the wrapper into Site.Master and inject our content into the wrapper's content area, and then r...

Can an Action Filter have access to a private object in the Controller?

I have public class FundController { private Site _site; public ViewResult Fund() { } } I'd like to add an Action Filter to this Fund method: public class FundController { private Site _site; [MyFilter] public ViewResult Fund() { } } but the Action Filter needs access to _site. Is this possib...

Is it possible to optimize ASP.NET WebForms to perform as fast as ASP.NET MVC?

There's so much hype about ASP.NET MVC these days, but the truth is that ASP.NET webforms is not going anywhere for some time. Is there any way for current developers to optimize ASP.NET webforms to perform as fast as ASP.NET MVC? I have noticed a significant difference in speed between ASP.NET MVC and ASP.NET webforms. MVC is a lot sna...