asp.net-mvc

Benefits of using FormViewModel in Controllers vs. Partial Model Class in Models

Hello everybody, I am having a difficult time understanding two design approaches in terms of long time extensibility in my current ASP.NET MVC application. The ORM that I use for providing data is Linq2SQL. Which is just amazing to work with, BTW! Now I am having some trouble with the design of my model classes for my views. Currentl...

Url helper in java script

I'm using jquery lightbox for image gallery. Url to the button image is '../../Content/Lightbox/lightbox-btn-next.gif' That work fine if my url is 'localhost/Something1/Somtehing2' If I use another route like 'localhost/Something1/Something2/Something3' then url to button images is incorrect. Can I use Url.Action() inside .js files? T...

add a class attribute to an actionlink that has a routevaluedictionary

Im using an action link and passing in tRVD where tRVD is the following: <% RouteValueDictionary tRVD = new RouteValueDictionary(ViewContext.RouteData.Values); %> heres my link. <%= Html.ActionLink("Previous", "Index", tRVD)%> how do i add a class attribute to this href? i tried this: <%= Html.ActionLink("Previous", "Index", t...

Learn Asp.Net WebForms or Asp.Net MVC

It might be a dupe but I cannot find a straight answer. If a person is about to start learning web development over .Net framework, which technology should he go for ? Asp.Net WebForms Asp.Net MVC keeping in view these three aspects future scope complexity features Note: has done some WinForms programming using C# Thanks ...

DropDown list onchange event

HOw can i change content of ViewData on drop down list change using javascript in MVC View? ...

unit testing IDataErrorInfo with tryupdatemodel in MVC

Hi, I'm trying to unit test a controller action in which I call tryupdatemodel, but the validation does not fire. When I run my application the validation occurs and is fine. My guess is the the model binder is not loaded in test scenarios, how can I test my action ? here is the code Company object public partial class Company : ID...

How to perform PostBack operation in ASP.NET MVC?

In mvc the page is not get post back as in asp.net then how can we perform postback operations in asp.net mvc2. for ex how to perform particular action when someone selects a chech box? Thanks in Advance ...

DropDown list onchange event and AJAX in MVC

I have a code black in my MVC view as follows: <%using (Ajax.BeginForm("MyAction", new { action = "MyAction", controller = "Home", id = ViewData["selected"].ToString() }, new AjaxOptions { UpdateTargetId = "Div1" })) { %> <%=Html.DropDownList("ddl", ViewData["MyList"] as SelectList, new { onchange = "this.form.submit()" }...

Showing data by joining 2 or more tables and performing updation in 2 or more tables in a MVC application.

I have prepared a web project using ASP.net MVC. I want to display data by joining 2 or more tables and on Edit performing updation in 2 or more tables. I have 2 tables : Employee_master(EmpID,Name,Designation) Employee_Detail(EmpId,Address,Phone,DOB). I am using ADO.Entity framework to create the model.I want to perform following ope...

Is my web.config file redirecting the /stats/ page?

I'm hosting an ASP.Net MVC site on GoDaddy. The site is in the root directory, and when I try to go to http://mydomain.com/stats, it redirects me to my MVC's logon page. I have no stats controller or view in my application, so it's not that it's hitting the wrong page. I contacted GoDaddy and they said it was most likely something i...

Passing a {sitename} parameter to MVC controller actions

How can I retrieve a site-wide URL parameter in a route without cluttering each controller action with a parameter? My question is similar to this question, but I want to avoid the ModelBinder clutter. Ie. in Global.asax.cs: routes.MapRoute( "Default", // Route name "{sitename}/{controller}/{action}/{id}", new { sitename = "...

New ASP.NET MVC 2 ViewMasterPage error

Im trying out ASP.NET MVC 2 and have immediately hit a problem with my first application.When adding a View Master Page I get the following warning in VS 2008: \Views\Shared\ViewMasterPage.Master: ASP.NET runtime error: The specified module could not be found. (Exception from HRESULT: 0x8007007E)Why is this? The System.Web.Mvc dll is in ...

Passing Collection to MVC.NET HtmlHelpers More Efficiently? Suggestions?

Hi all I have a Html helper method with the following signature: public static string MyActionLink(this HtmlHelper html , string linkText , List<KeyValuePair<string, object>> attributePairs , bool adminLink){} I have another utility then that takes all the attribute pairs and merges them to the tag as attribute/value pairs: Extensio...

Prototype post data not going through to asp.net mvc Actionrequest

Need assistance please. (More confused than anything really) I've got ASP.NET mvc controller [AcceptVerbs(HttpVerbs.Post)] public ActionResult Dashboard(string Whatever) { //Save name to database System.IO.StreamWriter swLogFile = new StreamWriter(@"c:\temp\test.txt", true); swLogFile.WriteLine(Convert.T...

Should the AntiForgeryToken be applied to every post action?

Should the AntiForgeryToken be applied to every post action in an ASP.NET MVC application? Off the top of my head I can't think of any reason why you would not want to include this on every post action, but it seems that nobody ever actually recommends using it on all of your actions. I'd love to hear your thoughts. ...

ASP MVC - Having different action handlers invoked depending on query params?

I would like different a different action to handle a request depending on query parameters values. For example: mydomain.com/controller/action?version=1&msg=hello and mydomain.com/controller/action?version=2&msg=5 should go to a different handlers based on the version value. The list of query params required/optional, as well as...

ASP.NET MVC: SelectList ignores selectedValue parameter in constructor

Hi, I've got the following in my view: <%= Html.DropDownList("Schema.MetaData.SourceTableName", new SelectList(Model.Schema.MetaData.SourceTableNames, Model.Schema.MetaData.SourceTableName), Model.SourceTablesOptionLabel)%> SourceTableNames is of type List<string> When I populate the model, I assign the value for SourceTableName usin...

allow html in text boxes asp.net mvc

Hi, im using asp.net mvc... how can I allow users to enter html into a textbox... im seting validaterequest to false and still getting this error: A potentially dangerous Request.Form value was detected from the client (Summary="<a>"). i know its not recommended etc, but it's for internal use. ...

How to implement Unit of work in MVC: Responsibility

Who has the responsability Who has the responsibility to start and finish the Unit of work in a MVC architecture? ...

FluentNhibernate mapping one-to-one

Hi, I have inhertited an legacy application, that I have little control over. I need to map a one to one relationship because "A user may have one of these, lets call them 'a Rejection', but not more than one" The data stored in the Rejection table is quite large. Anyway, I have simplyfied this model, using cats, dogs and an owner. An ...