My question is similar with this but the answer does not work for me as a linkbutton behaves differently than normal sorting headings.
Our website uses Server.Transfer
to hide different page access under a unique URL. Clicking on a asp:LinkButton
will lead to the front page, and not just sorting the gridview.
When looking at the client page code, I observed that the tool tip of a normal column header looks like
javascript:__doPostBack("(grid view control id)","Sort$(field name)");
and on a column with custom header template using LinkButton, it is
javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(
"(link button control id)", "", true, "", "", false,true);
I think the difference is the cause.
How to make them behave the same?
Update
I noticed that for a asp:Button
rather than link button, the javascript click event calls
javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(
"(button control id)", "", true, "", "", false, false);
And it is not leading to the front page.
So it seems I only need to set up so that the link button does not do a client side submit. But what is the best way to do so?