TAILIEUCHUNG - Pro ASP.NET MVC Framework phần 2

Sau 4 năm nghiên cứu với một loạt những phiên bản beta ở các năm 2000 và 2001, đã được công bố vào tháng 1 năm 2002, sau đó là version ở tháng 4 năm 2003. Mô hình code-behind của đánh dấu một bước tiến so với người anh em ASP, nó khuyến khích người viết web trên nền .NET xây dựng những ứng dụng với sự tách bạnh rõ ràng giữa các thành phần hiển thị và nội dung mặc dù vẫn có thể viết theo style của ASP, mọi xử lý viết thẳng vào. | CHAPTER 2 YOUR FIRST MVC APPLICATION 33 Figure 2-15. The validation feature working Note If you ve worked with WebForms you ll know that WebForms has a concept of server controls that retain state by serializing values into a hidden form field called VIEWSTATE. Please rest assured that MVC model binding has absolutely nothing to do with WebForms concepts of server controls postbacks or ViewState. MVC never injects a hidden VIEWSTATE field or anything of that sort into your rendered HTML pages. Finishing Off The final requirement is to e-mail completed RSVPs to the party organizer. You could do this directly from an action method but it s more logical to put this behavior into the model. After all there could be other UIs that work with this same model and want to submit GuestResponse objects. Add the following methods to GuestResponse 6 public void Submit EnsureCurrentlyValid Send via email var message new StringBuilder Date 0 yyyy-MM-dd hh mm n 6. You ll need to add using System using and using too . by using the Ctrl dot technique again . 34 CHAPTER 2 YOUR FIRST MVC APPLICATION RSVP from 0 n Name Email 0 n Email Phone 0 n Phone Can come 0 n Yes No SmtpClient smtpClient new SmtpClient new MailMessage rsvps@ From party-organizer@ To Name will attend won t attend Subject Body private void EnsureCurrentlyValid I m valid if returns null for every property var propsToValidate new Name Email Phone WillAttend bool isValid x this x null if isValid throw new InvalidOperationException Can t submit invalid GuestResponse Ifyou re unfamiliar with C 3 s lambda methods . x this x null then be sure to read the last part of Chapter 3 which explains them. Finally .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.