无法在aspx页面

时间:2017-07-25 11:12:55

标签: c# asp.net

我正在尝试填充ContentPlaceHolder中的表的数据,但它没有填充。早些时候我在另一个带有body标签的aspx页面中尝试了相同的代码,并在那里填充。这里我不能在ContentPlaceHolder中放置body标签。我将请求发送到web api以获取数据,我获取JSON格式的数据。我不确定,但我觉得ContentPlaceHolder有些不好。

<%@ Page Title="" Language="C#" MasterPageFile="~/RLCS_Connect/TLConnect_New.Master" AutoEventWireup="true" CodeBehind="ShowNoOfLocations.aspx.cs" Inherits="TLConnect_Staffing.RLCS_Connect.ShowNoOfLocations" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div>  
        <h2><b>Location Table:</b></h2>  
        <table id="Location" cellpadding="3" cellspacing="3" border="2" width="600px">  
            <tr>  
                <td style="background-color: gray; color: white">Cl_stateid</td>  
                <td style="background-color: gray; color: white">SM_Name</td>  
                <td style="background-color: gray; color: white">CL_CityID</td>  
                <td style="background-color: gray; color:white">LM_Name</td>  
                <td style="background-color: gray; color:white">CL_BranchName</td>  
                <td style="background-color: gray; color:white">CL_BranchAddress</td> 
                <td style="background-color: gray; color:white">CL_OfficeType</td> 
                <td style="background-color: gray; color:white">CL_EstablishmentType</td> 
            </tr>  
        </table>  
    </div>  
    <asp:HiddenField ID="HFClientId" runat="server" />

    <script src="Scripts/jquery-3.1.1.min.js"></script>
    <script type="text/javascript">
        var uri = 'http://localhost:62983/api/ClientDetail/NoOfLocations';
        $(document).ready(function () {
            var id = $('#HFClientId').val();
            $.getJSON(uri + '/' + id)
            .done(function (data) {
                $.each(data, function (key, item) {
                    $('#Location').append("<tr><td>" + item.Cl_stateid + "</td>" +
                        "<td>" + item.SM_Name + "</td>" + "<td>" + item.CL_CityID + "</td>" +
                        "<td>" + item.LM_Name + "</td>" + "<td>" + item.CL_BranchName +
                        "<td>" + item.CL_BranchAddress + "<td>" + item.CL_OfficeType + "</td>" + "<td>" + item.CL_EstablishmentType + "</td></tr>");
                });
            });
        });

    </script>  
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
</asp:Content>

0 个答案:

没有答案