TAILIEUCHUNG - ASP.NET 4 Unleased - p 118

Trong trường hợp này, mặc định cung cấp là "thuốc nổ" thể loại. Các trang mục tiêu không cần phải biết rằng nó đã được gọi với một giá trị mặc định, nó chỉ đơn giản là có thể lấy tên thể loại từ điển RouteData. | 1144 CHAPTER 25 Using the URL Routing Engine In the following route configuration we have a category browser page that we can reach with the category name route pattern. If the user doesn t supply a category name we supply a default URL pattern with defaults category-browse category categoryname - true new RouteValueDictionary categoryname explosives In this case the default supplied is the explosives category. The target page doesn t need to know that it was invoked with a default value it can simply grab the category name from the RouteData dictionary. Supplying defaults is useful both for creating default landing options for hitting pages without parameters but also so that the target page doesn t need to be cluttered up with conditional statements checking to see whether particular values have been supplied in route data. Using Constrained Routes For a lot of situations the type of route patterns that we have discussed thus far are sufficient. If you want static routes or routes with simple parameters with or without defaults you are all set. However if you want to further constrain your route patterns so that only after certain conditions are met should your route be invoked you re also in luck. One of the overloads of the MapPageRoute method that we haven t yet discussed actually takes a dictionary of constraints to route parameters. These constraints come in the form of regular expressions. We warned you earlier that we d have to talk about them eventually. At their simplest level you can use these regular expressions to limit the size of parameters so that when passing a state code on the URL the code must be only two characters and must not contain numbers. Anyone familiar with regular expressions also knows that you can create incredibly powerful expressions that do far more than just simple validation. Regular expressions are outside the scope of this book so we re going to use some simple expressions to .

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.