Mal
Mal

Reputation: 525

C# event using jQuery

I need ASP.NET C# button click event to be done by the jQuery. The following sample code taken from my project in which instead of document.write('Passed') I need C# button click even to be done. How it can be done?

Sample code in which button click Button1_Click to be replaced instead of document.write

$("#slider").draggable({
        axis: 'x',
        containment: 'parent',
        drag: function(event, ui) {
            if (ui.position.left > 550) {
                document.write('Passed');
                $("#well").fadeOut();
            } else {
            }
        }

Upvotes: 4

Views: 982

Answers (2)

ipr101
ipr101

Reputation: 24236

I'm not sure if this is what you want, but you could trigger the 'click' event for the button on the page using jQuery. This would cause your event to fire server side, as it would if the button had been manually clicked -

$('#yourbuttonid').trigger('click');

Upvotes: 3

sikender
sikender

Reputation: 5921

I'm little confused here now. But This is what you want to be replace document.write

$("#Button1").click(function() {
                        alert("Hello world!");
                    });

Upvotes: 1

Related Questions