asp.net-mvc-3

How do I access data in a view in Razor?

為{幸葍}努か 提交于 2020-01-15 10:54:36
问题 In standard WebForms, I would have a handful of properties, and set those. Then the Web Page would bind to them, for example with <%#CustomerName%> . I understand that MVC is a different approach, but there must still be a basic need for displaying data from multiple sources at the same time. I can see that if I use @Model then it will access the data set in the controller. But what if You want to display data from 2 or 3 separate items? If I want to display a Customer , their address and

How do I access data in a view in Razor?

自闭症网瘾萝莉.ら 提交于 2020-01-15 10:53:44
问题 In standard WebForms, I would have a handful of properties, and set those. Then the Web Page would bind to them, for example with <%#CustomerName%> . I understand that MVC is a different approach, but there must still be a basic need for displaying data from multiple sources at the same time. I can see that if I use @Model then it will access the data set in the controller. But what if You want to display data from 2 or 3 separate items? If I want to display a Customer , their address and

How do I access data in a view in Razor?

廉价感情. 提交于 2020-01-15 10:53:34
问题 In standard WebForms, I would have a handful of properties, and set those. Then the Web Page would bind to them, for example with <%#CustomerName%> . I understand that MVC is a different approach, but there must still be a basic need for displaying data from multiple sources at the same time. I can see that if I use @Model then it will access the data set in the controller. But what if You want to display data from 2 or 3 separate items? If I want to display a Customer , their address and

How do I access data in a view in Razor?

跟風遠走 提交于 2020-01-15 10:53:24
问题 In standard WebForms, I would have a handful of properties, and set those. Then the Web Page would bind to them, for example with <%#CustomerName%> . I understand that MVC is a different approach, but there must still be a basic need for displaying data from multiple sources at the same time. I can see that if I use @Model then it will access the data set in the controller. But what if You want to display data from 2 or 3 separate items? If I want to display a Customer , their address and

Convert webform control to Razor syntax

不羁的心 提交于 2020-01-15 10:44:45
问题 i got this control and it works fine, but i need to use it on my mvc3 project. I tryed my way but didnt work. I hope someone can help me. Thats the webform custom control code: ASPX: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="BoletoCS.aspx.cs" Inherits="BoletoCS" %> <%@ Register Assembly="Impactro.Cobranca" Namespace="Impactro.WebControls" TagPrefix="cob" %> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Boleto</title> <style type="text/css">

MVC3 Razor JQuery client side validation with an additional alert box

霸气de小男生 提交于 2020-01-15 10:15:49
问题 I am being asked to create a login form that when the user input doesn't pass validation it pops an alert box. I have everything wire up using the model based validation. ex: public class LogonViewModel { [Required( ErrorMessage = "User Name is Required")] public string UserName { get; set; } [Required( ErrorMessage = "Password is required")] public string Password { get; set; } } I have a validation summary on the page: Html.ValidationSummary() I would like the summary to be on the page just

MVC3 Razor JQuery client side validation with an additional alert box

白昼怎懂夜的黑 提交于 2020-01-15 10:15:31
问题 I am being asked to create a login form that when the user input doesn't pass validation it pops an alert box. I have everything wire up using the model based validation. ex: public class LogonViewModel { [Required( ErrorMessage = "User Name is Required")] public string UserName { get; set; } [Required( ErrorMessage = "Password is required")] public string Password { get; set; } } I have a validation summary on the page: Html.ValidationSummary() I would like the summary to be on the page just

If I wanted to use attributes to muck about with an MVC return contentType, would it be better to do it in OnResultExecuting or OnResultExecuted?

Deadly 提交于 2020-01-15 10:09:57
问题 In the pursuit of solving an absurd problem, I need to append a value to my querystring (did that in javascript) and test if it exists on the server (because this may come from ajax or an iframe, so there's no header potential, sadly, and I'm trying to avoid adding a value to my <form> element). To that end, I've devised this little snippet, and I'm not sure where to put the "setter" block: using System.Web.Mvc; namespace Company.Client.Framework.Mvc { class CreateFormDialogResponseAttribute

MVC3 razor remote validation - Controller argument is always empty

非 Y 不嫁゛ 提交于 2020-01-15 09:08:08
问题 I can call the controller but the argument (string) is always null. All the examples I have found name the controller argument the same as the property we are validating remotely, sounds good/easy, but if you look at fiddler what is really being passed in is the name attribute from the input statement. Well that is problematic in that it is a subscripted name something like Person.EMailAddresses[0].Address , well I can't name my controller parameter like that. So how do I get around this?

One to Many with Entity Framework not updating the foreign key

夙愿已清 提交于 2020-01-15 09:05:32
问题 I need some help, I have been searching everywhere for ages to why this keeps happening. I basically have 2 tables, Company and Address. A company can have multiple addresses. My classes and tables look like the following TABLES: create table Company ( companyid int PRIMARY KEY IDENTITY not null, name varchar(100), agencyref varchar(20), website varchar(100), phoneno varchar(20), faxno varchar(20), modified datetime DEFAULT (GETDATE()) ); create table Address ( addressid int PRIMARY KEY