Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In Server, I have a DeviceData class which has DeviceName and IPAddress properties. These values are sent to my webClient(Html) using SignalR

C#
public class DeviceData
  {
      public string DeviceName { get; set; }
      public string IPAddress { get; set; }

  }


On my Client when I click a button (GetDeviceData), I get the details from Server, but I am able to upload the details in the object on to my html table.

Here is my html code:

XML
<body>
    <h1>Device List</h1>

    <div id="DeviceTable">
        <table border="1">
            <thead>
                <tr><td>DeviceName</td><td>IPAddress</td></tr>
            </thead>
            <tbody>
                <tr class="loading"><td colspan="5">loading...</td></tr>
            </tbody>
        </table>

        <input type="button" id="GetDeviceData" value="GetDeviceData" />
    </div>

  <!--Script references. -->
        <!--Reference the jQuery library. -->
        <script src="Scripts/jquery-1.6.4.min.js" ></script>
        <!--Reference the SignalR library. -->
        <script src="Scripts/jquery.signalR-2.1.2.min.js"></script>
        <!--Reference the autogenerated SignalR hub script. -->
    <script src="signalr/hubs"></script>
    <script type="text/javascript">
        $(function () {
            //Set the hubs URL for the connection
            var url = 'http://localhost:8080/signalr';

            var connection = $.hubConnection(url);

            // Declare a proxy to reference the hub.
            var hubProxy = connection.createHubProxy('HubClass');

            //var DeviceTextBox = $('#message');
            var $DeviceTable = $('#DeviceTable');
            var $DeviceTableBody = $DeviceTable.find('tbody');
              var rowTemplate = '<tr><td>DeviceName</td><td>IPAddress</td></tr>';

            hubProxy.on('DeviceDataResults', processDeviceDataResults);

            connection.start().done(function () {
                $('#GetDeviceData').click(function () {

                    hubProxy.invoke('GetDeviceData');
                });


            });



            function processDeviceDataResults(DeviceName) {

                $DeviceTableBody.empty();

               //Here I need to upload my table data



            };
        });



        </script>
Posted
Comments
Sergey Alexandrovich Kryukov 2-Oct-14 0:26am    
"I am unable..." is not informative. It needs comprehensive information on the problem. Any exceptions?
—SA
[no name] 7-Oct-14 6:19am    
do you wanna render the html table dynamically according to your server datas? is that your requirement ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900