Click on page number of grid view working in ie8 but not in ie9.
Hi
I have a
gridview with paging enabled. I am handling
beforeunload from clientside wherein i am
calling a code behind function. When i click on page number the page gets unloaded,which is not desired . So i have aded below piece of code on my page number click to prevent call to code behind function.
The problem is the code worked in ie 8, but doesnot work in ie9.
-----------------------------------------------------------------------JS/JQ-----------------------------------------------------------------
<script src="scripts/jquery-1.8.2.js" type="text/javascript"></script>
<script src="scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
//set a flag.
var flag = true;
// $(document).ready(function () {
$(function () {
$('.pagerr a').click(function () {
//when gridview page index clicked, change the flag......
flag = false;
});
});
$(window).bind('beforeunload', unlockAlert);
function unlockAlert(event) {
if (flag) {
//calling code behind function here
});
}
flag = true
}
</script>
----------------------------------------------------------------------asp:gridview---------------------------------------------------------
<asp:GridView ID="gv" runat="server" Width="100%" AllowPaging="True" AllowSorting="True" BorderColor="Black"
AutoGenerateColumns="False" PageSize="5"
<HeaderStyle Font-Size="8pt" Font-Names="Arial" Font-Bold="True" HorizontalAlign="Left"
ForeColor="Black" VerticalAlign="Middle" BackColor="#A0C6E5"></HeaderStyle>
<FooterStyle Font-Size="8pt" ForeColor="Black" BackColor="#A0C6E5"></FooterStyle>
<PagerSettings Position="Top" />
<Columns>
<asp:BoundField DataField="field1" HeaderText="field1">
<HeaderStyle Width="140px" HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<PagerStyle CssClass="pagerr"></PagerStyle>
</asp:GridView>