1

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

Chris
  • 2,953
  • 10
  • 48
  • 118
  • What server-side technology are you using? – Jasen May 15 '15 at 23:34
  • @Jasen, sorry, I am using ASP.NET and C# – Chris May 15 '15 at 23:36
  • 2
    Probably your biggest obstacle will be [getting those control Ids into the external javascript file](http://stackoverflow.com/questions/17702953/getelementbyid-in-separate-js-file-doesnt-find-asp-net-control). – Jasen May 15 '15 at 23:49
  • @Jasen, That worked exactly like I wanted it to. If you want to post that somehow as an answer I would be more than happy to accept. It saved me a lot of grief. – Chris May 15 '15 at 23:54
  • If helpful, you should vote that question up instead of creating duplicate ones. Glad to help. – Jasen May 15 '15 at 23:57
  • @Jasen, I'll do that now. – Chris May 15 '15 at 23:58
  • Can't you make the controlids a hidden variable on your page then give it an html id then call it with 'document.getElementById(htmlid)'? – imGreg May 16 '15 at 03:57

1 Answers1

1

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.

jomargon
  • 169
  • 1
  • 8