user3428422
user3428422

Reputation: 4560

Javascript call to server side function without AJAX or PageMethods

I know how to get to the server side using AJAX, JSON and even PageMethods, however, I am working with an old application and using these technologies isn't allowed. (Shame I know)

I currently have a ondblclick event on a AspListBox object that fires some javascript which brings up a dialog.

ondblclick="Window('object'); return false;"

function Window(object) {

var window = object

// blah

}

Working as it should, but I need to populate some values that belong in this dialog from the database, so therefore going to the server.

How can I do this from the javascript?

I use to many moons ago fire the serverside method that belonged in a hidden aspxButton within a javascript function.

// Causes a postback but this is how it will only work now...
document.getElementById('buttonId').click(); 

is this my best way around this still? Or is there another method?

Thanks

Upvotes: 0

Views: 535

Answers (1)

alpham8
alpham8

Reputation: 1362

Yes, there is one! You could send an XMLHttpRequest to your Server. This is also possible to hook the form POST format for it. But notice, that this isn´t a standard JavaScript implementation. So you Need to implement also cross-browser Support. If you would like to use a finished solution, which already implented this, I would advise you to use jQuery.

If you got this, you need now to place it somewhere inside you JS code. The best way for doing it, is to register an event after the ListBox is filled up.

Upvotes: 1

Related Questions