Wednesday, November 17, 2010

Avoiding Flickering in jQuery

Avoiding Flickering in jQuery on moss application
Refer
http://avinash-moss-expert.blogspot.com/2010/11/flickering-issue-with-jquery-in.html

Remove page flicker in sharepoint

refer
http://avinash-moss-expert.blogspot.com/2010/11/flickering-issue-with-jquery-in.html

flickering issue with jquery in sharepoint

Hi,

I had flickering issue on sharepoint site when i try to use jQuery. I search lots but none of solution works for me.Few solution are there on some blogs like:-
http://weblogs.asp.net/wesleybakker/archive/2008/12/29/Eliminate-page-flicker-in-SharePoint.aspx
http://weblogs.asp.net/wesleybakker/
http://www.alligatortags.com/alligatortags-12-29-2008.html
http://www.developerit.com/en/search/page-138/get-the-title
http://www.psearch.info/s/irritating-flicker-postbacks-server
as per these above blogs below code solve issue
<meta http-equiv="Page-Exit" content="blendTrans(Duration=0.0)" />
but all these does not solve my issue. Finaly i got solution which is mentioned below:-

In sharepoint we start using jQuery or JavaScript like below:-
<script type="text/javascript">

_spBodyOnLoadFunctionNames.push("RoundCorner");
function RoundCorner() {
// all js code will come here
$('div.graybackground').corner("round");
// all js code will come here
}
</script>

I add two lines extra in script and replace function as below:-
<script type="text/javascript">

_spBodyOnLoadFunctionNames.push("RoundCorner");
function RoundCorner() {
$('body').css('display', 'none');
// all js code will come here
$('div.graybackground').corner("round");
// all js code will come here
$('body').css('display', 'block');
}
</script>

 
Thanks!
Avinash

Wednesday, November 10, 2010

custom pagination in gridview

If you want to implement custom pagination having "Next" and "Prev" button in gridview then you have following options:-

http://www.codeproject.com/KB/aspnet/CustomPagingForGridview.aspx
http://msdn.microsoft.com/en-us/library/aa479347.aspx
http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

But i have got one more good solution which works well for me. See below:-

GridView1.PagerSettings.Mode = PagerButtons.NumericFirstLast;
GridView1.PagerSettings.NextPageText = ">";
GridView1.PagerSettings.PreviousPageText = "<"; GridView1.PagerSettings.LastPageText = ">>";
GridView1.PagerSettings.FirstPageText = "<<";

GridView1.RowDataBound+=new GridViewRowEventHandler(GridView1_RowDataBound); 
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
{
 if (e.Row.RowType == DataControlRowType.Pager) 
{ Table pagerTable = (Table)e.Row.Cells[0].Controls[0]; 
TableRow pagerRow = pagerTable.Rows[0]; 
PagerSettings pagerSettings = ((GridView)sender).PagerSettings; 
int cellsCount = pagerRow.Cells.Count; 
if (pagerSettings.Mode == PagerButtons.Numeric || pagerSettings.Mode == PagerButtons.NumericFirstLast) {
 int prevButtonIndex = pagerSettings.Mode==PagerButtons.Numeric ? 0 : 1; 
int nextButtonIndex = pagerSettings.Mode==PagerButtons.Numeric ? cellsCount-1 : cellsCount-2; 
if (prevButtonIndex < cellsCount) 
{ //check whether previous button exists LinkButton btnPrev = pagerRow.Cells[prevButtonIndex].Controls[0] as LinkButton; if (btnPrev != null && btnPrev.Text.IndexOf("...") != -1) btnPrev.Text = pagerSettings.PreviousPageText; 

if (nextButtonIndex > 0 && nextButtonIndex < cellsCount)
{
//check whether next button exists
LinkButton btnNext = pagerRow.Cells[nextButtonIndex].Controls[0] as LinkButton;
if (btnNext != null && btnNext.Text.IndexOf("...") != -1)
btnNext.Text = pagerSettings.NextPageText;
}
}
}
}

Thanks!
Avinash