After a page is loaded I call some ajax methods, where some html elements are created, for example
$.ajax({
...
success: function (data) {
...
var myCoolLink = $("<a/>").attr('id', 'xyz')
.attr('onclick', 'doStuff()')
.appendTo(someOtherElement);
}
});
The problem is that when myCoolLink is clicked, I want it to fire someFunction (with some arguments) in codebehind so that I can retrieve data to update a grid next to it.
Possible solutions and their problems:
- Change it to a LinkButton and add CommandArgument
CommandArgument is a server-side property, changing it won't mean a thing to the page.
- Add __doPostBack() in myCoolLink
Well, it will postback, but as I can't add runat="server" in my link (the same reasoning from the possible solution above) it won't do much besides this
The more I think about it the more I'm convinced this isn't possible. Either way, workarounds to my problem are always welcome! Looking forwards to your answers (: