mardi 8 décembre 2015

How to call button click event after controller postevent?

How to call button click event after controller postevent?

here is my view where i have a text box to enter notification messafe and on button click it should save data to database and should send the notification to clients using the code in the script section . Here it calls the http post event but the code in the jquery also firing but the notification is not sending . notifications.server.sendNotifications(); is not firing .

    @using (Html.BeginForm())
        <div class="publishContainer">
            @Html.TextAreaFor(model => model.Text, new { @placeholder = "Whats in your mind !!" })</div>
            <input id="button1" type="submit" value="button" />
    @section Scripts {
        <script src="~/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="~/Scripts/jquery.signalR-1.1.4.js" type="text/javascript"></script>
        <script src="~/signalr/hubs"></script>
        <script type="text/javascript">
            $(function () {
                var notifications = $.connection.notificationHub;
                // Start the connection.
                $.connection.hub.start().done(function () {
                    $("#button1").click(function () {

                    }).fail(function (e) {

    and the controller Post event 

            public ActionResult Notification(Notification notification)
                if (ModelState.IsValid)

                    //var hub = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>();

                    //NotificationHub obj = new NotificationHub();


                return View(notification);

This will call the http Post event but it is not firing the jquery event where i have the signal r hub methos.

Aucun commentaire:

Enregistrer un commentaire