I have a ASP.NET button but recently, I replaced it with a standard HTML button ... What I need to do is a postback to an ASP.NET page and ensure a method is called.
I came across this post through google so I suspect others will too. I tried the methods on here which didn't work for me. I will explain my solution, but first an overview of what I'm trying to do.
I have a form that uses jQuery ajax to post data to my webservice which in turn updates my database. I have an image upload form, for security reason you can't get the full file path to use in the ajax call to pass to the webservice... so it has to be done with a regular asp.net postback. So my dilemma is how to do both. What I did was use my ajax function to update the database, once I got a success back from the webservice I tell the form to do a postback to a certain method in the codebehind and then redirect to wherever.
$("#Button1").click(function () {
javascript: __doPostBack('ctl00$ContentPlaceHolder1$atest', '')
});
This is essentially exactly the same as assigning a click function to an asp.net control, except instead of clicking the button I am telling javascript to execute it.
atest
would be the ID i assigned to the asp.net control.
Note: the <%=myclientid.ClientID %>
will not work here.