2011-06-28 78 views
0

我的代码是:我的代码在部分视图(ascx)中不起作用?

<script type="text/javascript"> 
    $(document).ready(function() { 
     alert("dd"); 
     //Attach cascading behavior to the orderID select element. 
     $("#orderID").CascadingDropDown("#customerID", '/Home/AsyncOrders', 
      { 
       promptText: '-- Pick an Order--', 
       onLoading: function() { 
        $(this).css("background-color", "#ff3"); 
       }, 
       onLoaded: function() { 
        $(this).animate({ backgroundColor: '#ffffff' }, 300); 
       } 
      }); 

     //Attach cascading behavior to the orderDetails select element. 
     $("#orderDetails").CascadingDropDown("#orderID", '/Sales/AsyncOrderDetails', 
      { 
       promptText: '-- Pick an Order Detail --', 
       onLoading: function() { 
        $(this).css("background-color", "#ff3"); 
       }, 
       onLoaded: function() { 
        $(this).animate({ backgroundColor: '#ffffff' }, 300); 

       } 
      }); 

     //When an order detail is selected, fetch the details using ajax 
     //and display inside a div tag. 
     $('#orderDetails').change(function() { 
      if ($(this).val() != '') { 
       $.post('/Sales/OrderDetails', $(this).serialize(), function (data) { 
        $('#orderDetailsContainer').html(data).effect("highlight", {}, 3000); 
       }); 
      } 
     }); 
    }); 
    </script> 

     <div id="searchFilter"> 
     Custom text in select lists, lists highlight when loading.<br /> 
     <%:Html.DropDownList("customerID", Model, "-- Select Customer --")%> 
     <%-- <%:Html.DropDownList("cites", ViewData["xml"] as SelectList , "-- Select Customer --")%>--%> 
     <select id="orderID" name="orderID"> 
     </select> 
     <select id="orderDetails" name="orderDetails"> 
     </select> 
    </div> 
    <div id="orderDetailsContainer"> 
    </div> 

,当它写在页面(ASPX)非常难得运行

,但在使用时局部视图(ASCX)不运行的代码?

+0

添加更多有关什么不工作的细节以及如何渲染局部视图 –

+0

嗨,这段代码使用前级联下拉列表,这是第一个显示列表单元,当它改变时,其他drodownlist显示本单元的列表。在页面(aspx)中使用此代码运行非常神,但使用Partial VIew(ascx)时不运行 – user818566

回答

0

确保你做任何这样的

<% Html.RenderPartial("YourUserControl"); %> 

或(注意冒号(:))

<%: Html.Partial("YourUserControl"); %> 

或者你的部分观点将不会被写入文件

相关问题