내 URL이 올바르게 작동하지만 정확한 컨트롤을 사용할 수는 있지만 어떻게하면 URL에서 상태 이름을 볼 수 있습니까?MVC2에서 쿼리 문자열 값을 읽고 전달하는 적절한 방법은 무엇입니까?
내 URL : http://localhost:10860/Listings/Arizona/page1
내보기 :
> "%><h2>Test BY STATE</h2>
<%
LOTW.Models.ListingRepository dr = new LOTW.Models.ListingRepository();
ListViewListings.DataSource = dr.GetByStateName(???? I can hard code "Arizona" and this works???????); // how do i grab the 'Arizona' from the url? Reqquest.Querystring doesn't work?
ListViewListings.DataBind();
%>
<%--Define the table headers to work with the tablesorter--%>
<asp:ListView runat="server" ID="ListViewListings">
<LayoutTemplate>
<table id="ListViewListings" class="tablesorter">
<thead>
<tr>.....
야 내가 좋아하는 당신 아이디어가 더 좋다 .... 내가 방금 찾은 것보다 ... request.querystring 대신 [...] ... RouteData.Values [ "stateName"]. ToString() ... 그러나 나는 대신 제어기에 넣을 것입니다 ... thanks x 10 – Bryant
마크 업에서 ' '컨트롤을 사용하지 않으려면 최대한 노력하십시오. 대신 MVC의 진정으로 무국적 인 성격을 포용하고 가능한 한 일반적인 HTML을 사용하십시오. 내 Views에서'DataSources' 또는' ' 컨트롤을 사용하는 이유를 아직 찾지 못했습니다. –