I'm having a problem with telerik RadGrid, I want to enable multiple row selection. I also want to go to the server whenever a row is selected or deselected. I created a javascript function to handle the Grid's client side events (OnRowSelected, and OnRowDeSelected). The functions look like this:
function onOperationRowSelected(sender, eventArgs) {
__doPostBack("<%=myControl.ClientID %>", "rowSelected:" + eventArgs.get_itemIndexHierarchical());
}
The other function is very similar, the only difference is that it sends the string "rowDeselcted" instead of "rowSelected".
On Page_Load I check to see if the request is a Post request using "IsPostBack" and if so, I check to see if it's a rowSelected or rowdeselected.
My problem is when I select a first raw on my grid, a Post request happens (which is expected), however, when I select the second row, a GET request is issued, which (obviously) will result in IsPostBack returning false.
What am I missing here?
EDIT: I just checked the Request object and found that the HttpMethod property value is "POST". How come it's an HTTP POST request and IsPostBack returns false??
Are you sure the GET request has the right event argument?
I think there is something else that is making the GET request. Probably some AJAX magic by that grid, some resource or AJAX PageMethod call or URL rewriting thing or something like that.
Is the page name default.aspx or something alike? Sometimes in some browser (can't remember details) getting an image or so (can't remember exact situation) makes the browser also hits the "samefolder/" URL, which opens the default page.
Check the request with FireBug and see what it tells.
The function respects the action of the
<form>
. Here's what __doPostBack does:So it'll do whatever the form is set to do, that's just typically post in asp.net.
So is it possible? Yes, absolutely, why it's occurring in your case I'm not sure.
Without seeing the markup that the grid generates, I'm assuming that it uses a link with a javascript-applied click handler to do the postback. I think the most likely culprit, then, is a javascript error which is preventing the handler from firing, which gives you the default behavior of the anchor to which the handler is applied, in this case a GET. Best advice I can give you is to look at it in Firefox/Firebug and see if there are any errors shown in the console.
That said, you might want to build the app so that it works if javascript is disabled and both correct the error and figure out how to respond if you do end up with a GET request.