Click here to Skip to main content
15,913,487 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionCombine AngularJS with Signalr in C# project. Pin
Member 1056128817-Apr-17 12:46
Member 1056128817-Apr-17 12:46 
Hi,

I am after some guidance how to incorporate angularjs into this project. I am looking for a nicer way of writing the data to the table. Any help would be most appreciated.

C#
public class RaceDayDisplayController : ApiControllerWithHub<RaceDayDisplayHub>
    {
        [HttpPost]
        [Route("api/DoSomething")]
        public HttpResponseMessage DoSomething(Rootobject model)
        {
            Hub.Clients.All.LastSectional(model.sectionTimes[0].runners);
        }
    }






HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Display</title>
</head>
<body>
    <h2>Real-Time Raceday Data</h2>

    <table id="showData"></table>

    <!--Script references. -->
    <!--Reference the Angular library. -->
    <script src="/Scripts/angular.js"></script>
    <!--Reference the jQuery library. -->
    <script src="/Scripts/jquery-1.10.2.min.js"></script>
    <!--Reference the SignalR library. -->
    <script src="/Scripts/jquery.signalR-2.1.2.js"></script>
    <!--Reference the autogenerated SignalR hub script. -->
    <script src="/signalr/hubs"></script>

    <script type="text/javascript">

        $(function () {
            var myHub = $.connection.raceDayDisplayHub;

            try {
                $.connection.hub.start();

                myHub.on('LastSectional', function (runners) {

                    $("#showData tr").remove();
                    $('#showData').append('<tr><td width="150">Pos</td><td width="210">Name</td><td width="150">Margin</td><td width="150">Last Sectional</td><td width="150">Cumulative Times</td></tr>');
                    for (var i = 0; i < runners.length; i++) {
                        $('#showData').append('<tr><td>' + runners[i].position + '</td><td>' + runners[i].bookNumber + ' ' + runners[i].name + '</td><td>' + runners[i].margin + '</td><td>' + runners[i].sTime + '</td><td>' + runners[i].cumTime + '</td></tr>');
                    }

                    //var runners = JSON.stringify(test)

                    //var app = angular.module('myApp', []);
                    //app.controller('customersCtrl', function ($scope) {
                    //    $scope.runners = runners;
                    //});
                });

            } catch (e) {
                alert(e.message);
            }

        });

    </script>

</body>
</html>

QuestionHow to interact windows forms app to asp.net c# web Pin
Zeyad Jalil17-Apr-17 2:18
professionalZeyad Jalil17-Apr-17 2:18 
AnswerRe: How to interact windows forms app to asp.net c# web Pin
Afzaal Ahmad Zeeshan17-Apr-17 2:30
professionalAfzaal Ahmad Zeeshan17-Apr-17 2:30 
QuestionUrgent Assistance Pin
Member 1313189416-Apr-17 10:35
Member 1313189416-Apr-17 10:35 
AnswerRe: Urgent Assistance Pin
Afzaal Ahmad Zeeshan16-Apr-17 10:48
professionalAfzaal Ahmad Zeeshan16-Apr-17 10:48 
GeneralRe: Urgent Assistance Pin
ZurdoDev17-Apr-17 2:03
professionalZurdoDev17-Apr-17 2:03 
SuggestionRe: Urgent Assistance Pin
ZurdoDev17-Apr-17 2:03
professionalZurdoDev17-Apr-17 2:03 
QuestionASP.NET MVC Exercise Pin
Moni Shakeera15-Apr-17 10:40
Moni Shakeera15-Apr-17 10:40 
AnswerRe: ASP.NET MVC Exercise Pin
Richard MacCutchan15-Apr-17 20:57
mveRichard MacCutchan15-Apr-17 20:57 
AnswerRe: ASP.NET MVC Exercise Pin
ZurdoDev17-Apr-17 2:04
professionalZurdoDev17-Apr-17 2:04 
QuestionASP.Net Web Application with Devices Pin
Zeyad Jalil14-Apr-17 1:02
professionalZeyad Jalil14-Apr-17 1:02 
AnswerRe: ASP.Net Web Application with Devices Pin
ZurdoDev14-Apr-17 1:15
professionalZurdoDev14-Apr-17 1:15 
GeneralRe: ASP.Net Web Application with Devices Pin
Zeyad Jalil14-Apr-17 3:51
professionalZeyad Jalil14-Apr-17 3:51 
GeneralRe: ASP.Net Web Application with Devices Pin
ZurdoDev14-Apr-17 3:59
professionalZurdoDev14-Apr-17 3:59 
QuestionIn RequireField validator textbox Data is present in the Textbox but its fired Please enter your cardnum1 Pin
Member 1312710613-Apr-17 12:36
Member 1312710613-Apr-17 12:36 
AnswerRe: In RequireField validator textbox Data is present in the Textbox but its fired Please enter your cardnum1 Pin
User 418025418-Apr-17 4:44
User 418025418-Apr-17 4:44 
QuestionHow to configure sql server profiler to see sql for my session only Pin
Tridip Bhattacharjee12-Apr-17 22:36
professionalTridip Bhattacharjee12-Apr-17 22:36 
AnswerRe: How to configure sql server profiler to see sql for my session only Pin
Richard MacCutchan12-Apr-17 23:48
mveRichard MacCutchan12-Apr-17 23:48 
AnswerRe: How to configure sql server profiler to see sql for my session only Pin
Eddy Vluggen13-Apr-17 0:32
professionalEddy Vluggen13-Apr-17 0:32 
GeneralRe: How to configure sql server profiler to see sql for my session only Pin
Tridip Bhattacharjee13-Apr-17 2:57
professionalTridip Bhattacharjee13-Apr-17 2:57 
QuestionHow SSRS handle large data Pin
Tridip Bhattacharjee12-Apr-17 22:31
professionalTridip Bhattacharjee12-Apr-17 22:31 
QuestionMVC, my views can't see or reference the namespace MvcApplication in Global.asax Pin
jkirkerx12-Apr-17 8:50
professionaljkirkerx12-Apr-17 8:50 
AnswerRe: MVC, my views can't see or reference the namespace MvcApplication in Global.asax Pin
Afzaal Ahmad Zeeshan12-Apr-17 9:17
professionalAfzaal Ahmad Zeeshan12-Apr-17 9:17 
GeneralRe: MVC, my views can't see or reference the namespace MvcApplication in Global.asax Pin
jkirkerx12-Apr-17 10:17
professionaljkirkerx12-Apr-17 10:17 
QuestionIs there a control that displays a PDF and submits the pdf back to the server? Pin
Michael Clinton11-Apr-17 9:18
Michael Clinton11-Apr-17 9:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.