J
James
Hi
The standard datagrid pager is rendered as a hyperlink e.g. <a
href="javascript:__doPostBack('...', '...')">
Apparently use of this javascript pseudo-protocol is bad practice, and
it was introduced to allow people to generate pages using javascript.
So of course it is all over ASP.Net and particularly the datagrid
pager.
One bad thing about this is that despite apparently not navigating to a
new page, because of the intention that the javascript would generate a
new page, this link when activated immediately fires the onbeforeupdate
event for the page. I have code in this event which I only want to run
when the page is being left for a new page, not when the page is merely
being posted back. I can find no way to use the ASP.Net datagrid
control and do this, particularly I can't tell that someone has just
clicked the pager on this control and is therefore not navigating to a
new page.
I thought there might be some means of determining the cause of the
onbeforeupdate event being fired but the event object does not support
srcElement or target in this case. I have tried 'hijacking' the
__doPostBack event by having some javascript which runs after the
declaration of __doPostBack rendered by the ASP.Net framework and
redefines __doPostBack to point to another function. I had hoped by
setting a flag in this function, I could tell that a post back was
occurring not a navigation to a new page. However because of this
hyperlink based invocation of __doPostBack, the onbeforeupdate event
fires before this code can set the flag.
I have tried to write an inheritor of DataGrid which messes with the
rendering of the pager, however although I can get at the LinkButton
child controls that the DataGrid creates for the pager, I can't get at
the href they render, and so I can't get the parameters that are passed
to __doPostBack nor can I generate them with any method on the Page
object.
Does anyone know of a workaround for this?
James
The standard datagrid pager is rendered as a hyperlink e.g. <a
href="javascript:__doPostBack('...', '...')">
Apparently use of this javascript pseudo-protocol is bad practice, and
it was introduced to allow people to generate pages using javascript.
So of course it is all over ASP.Net and particularly the datagrid
pager.
One bad thing about this is that despite apparently not navigating to a
new page, because of the intention that the javascript would generate a
new page, this link when activated immediately fires the onbeforeupdate
event for the page. I have code in this event which I only want to run
when the page is being left for a new page, not when the page is merely
being posted back. I can find no way to use the ASP.Net datagrid
control and do this, particularly I can't tell that someone has just
clicked the pager on this control and is therefore not navigating to a
new page.
I thought there might be some means of determining the cause of the
onbeforeupdate event being fired but the event object does not support
srcElement or target in this case. I have tried 'hijacking' the
__doPostBack event by having some javascript which runs after the
declaration of __doPostBack rendered by the ASP.Net framework and
redefines __doPostBack to point to another function. I had hoped by
setting a flag in this function, I could tell that a post back was
occurring not a navigation to a new page. However because of this
hyperlink based invocation of __doPostBack, the onbeforeupdate event
fires before this code can set the flag.
I have tried to write an inheritor of DataGrid which messes with the
rendering of the pager, however although I can get at the LinkButton
child controls that the DataGrid creates for the pager, I can't get at
the href they render, and so I can't get the parameters that are passed
to __doPostBack nor can I generate them with any method on the Page
object.
Does anyone know of a workaround for this?
James