Chris
Chris

Reputation: 3129

How to call a server side button click event from external JS file?

I have a toolbar that when an item is clicked that it calls a radconfirm window from an external js file, and when you click on the ok button it calls a callbackfunction, in the callbackfunction I am searching for Button1 to call its onclick event so I can add some code to delete a record from the database. I know this can be done when all the script is put into the markup, but I want to clean up the markup an put everything in an external js file.

The javascript is..

function CallConfirm() {
var oConfirm = radconfirm("howdy", confirmCallbackFn, 500, 500);
}

function confirmCallbackFn(arg) {
if (arg == true) //the user clicked OK
    {
        document.getElementById("<%=Button1.ClientID%>").click();
    }
else {
    document.getElementById("rbtnRefesh").click();
    }
}

Any idea's would be appreciated, other than "use ajax and a webmethod". I don't have any webmethods and I am not using the WebAPI either, just using a stored procedure.

Thanks

Upvotes: 1

Views: 1194

Answers (1)

jomargon
jomargon

Reputation: 169

Declare a global Javascript variable that contain the button ID name on the aspx page. After that, you can then reference this variable on the external JS files.

Upvotes: 1

Related Questions