[RESOLVED]Problem in paging

I used a data pager in my application,this shows the <a> tags for paging which is under a span tag, and the name of span tag is the name of the datapage which i given it at .aspx page.

Now my problem is i want to stop _doPostBack function of javascript and use my own function i use the follwing line for that

$("span['id*='Pager1] a").bind(‘click’, function() {

var pageId = $(this).text();

//some code here

return false;

But this function not work,i dont understand what is problem


Code is correct …it would work for html like this  <span id="Pager1"><a>1</a></span>, check generated html to see if it is same. Make sure you write it inside $(document).ready(function(){}); I tested it at my end and its working fine…obviously i replaced
var pageId = $(this).text() with alert($(this).text());


My html is as follows

<span id="ctl00_CPHPackage_Pager1"><span>1</span>&nbsp;<a href="javascript:__doPostBack('ctl00$CPHPackage$Pager1$ctl00$ctl01','')">2</a>&nbsp;

<a href="javascript:__doPostBack('ctl00$CPHPackage$Pager1$ctl00$ctl02','')">3</a>&nbsp;

<a href="javascript:__doPostBack('ctl00$CPHPackage$Pager1$ctl00$ctl03','')">4</a>&nbsp;

<a href="javascript:__doPostBack('ctl00$CPHPackage$Pager1$ctl00$ctl04','')">5</a>&nbsp;&nbsp;

<a href="javascript:__doPostBack('ctl00$CPHPackage$Pager1$ctl00$ctl05','')">...</a>&nbsp;


Now my problem is it works first time correctly,but when i click second time on this paging ,then my my jquery function is not called and postback occurs

if you have registered the function in document.ready…it should not cause problem if it is normal postback (I assume you are not using updatepanel)…and i dont understand the __doPostBack in href ?? 


Actualy i use Jquery Load Function to load data and the data it load contains paging by datapager therefore __doPostBack comes in href,actually my problem is solved now i using live in place of bind…

Thanks for your support,if you have some comments on that then i feel pleasured

I would have suggestedt to use "live" if you were using updatepanel….partial postback unregisters the event you write using jquery and recreates the DOM …."live" attaches event for those newly created DOM elements.



Leave a Reply