网页生命周期需要帮助 [英] Webpage life cycle help needed
问题描述
大家好......我对页面生命周期有疑问......至少我认为问题出在哪里。
我有编写了一些代码,使用PagedDataSource动态创建分页按钮。除了一个小问题之外,这一切都按预期工作:-(
有一个标签显示当前页面和总页数..但它只会更新到正确的我第二次点击时的当前页面。任何帮助都会非常感激...(我正试图避开J Query,因为我真的没有多少经验。
这是Draw按钮方法。
private void DrawButtons()
{
Button pagerButtonFirst = new Button();
Button pagerButtonLast = new Button();
pagerButtonFirst.Text = first;
pagerButtonFirst.Click + = btnFirst_Click;
pagerButtonFirst.CssClass = PageEnds跨度>;
pnlButtonFirst.Controls.Add(pagerButtonFirst);
var paging =(Paging)Session [Globals.SessionsNames.SessTestimonials];
for ( int i = 0 ; i < paging.PagedSource.PageCount; i ++)
{
var newButton = new Button();
newButton.Text =(i + 1 )。ToString();
newButton.Command + = btnSpecfic_Click;
newButton.CommandArgument =(i + 1 )。ToString();
newButton.CssClass = PageNumber;
pnlButtonPages.Controls.Add(newButton);
}
pagerButtonLast.Text = last;
pagerButtonLast.Click + = btnLast_Click;
pagerButtonLast.CssClass = PageEnds;
pnlButtonLast.Controls.Add(pagerButtonLast);
lblPageInfo.Text = string .Format( 显示{1}的页面{0}。(总项{2}),
paging.PagedSource.CurrentPageIndex + 1 ,paging.PagedSource.PageCount,
paging.TotalItems.ToString());
}
请查看我的问题。同时,研究一下: http://msdn.microsoft.com/en-us/library/ms178472 .aspx [ ^ ] 。
如果从这一点开始,你会找到所有答案。
-SA
Hi all... I have a question about page life cycles... at least that''s where I think the problem lies.
I have written some code to dynamically create paging buttons using a PagedDataSource. It all works as intended apart from one small problem :-(
There is a label showing the current page and total pages.. but it only gets updated to the correct current page when I click for a second time. Any help would be MUCH appreciated... (I''m trying to steer clear of J Query as I really don''t have much experience with it.
This is the Draw buttons method.
private void DrawButtons()
{
Button pagerButtonFirst = new Button();
Button pagerButtonLast = new Button();
pagerButtonFirst.Text = "first";
pagerButtonFirst.Click += btnFirst_Click;
pagerButtonFirst.CssClass = "PageEnds";
pnlButtonFirst.Controls.Add(pagerButtonFirst);
var paging = (Paging)Session[Globals.SessionsNames.SessTestimonials];
for (int i = 0; i < paging.PagedSource.PageCount; i++)
{
var newButton = new Button();
newButton.Text = (i + 1).ToString();
newButton.Command += btnSpecfic_Click;
newButton.CommandArgument = (i + 1).ToString();
newButton.CssClass = "PageNumber";
pnlButtonPages.Controls.Add(newButton);
}
pagerButtonLast.Text = "last";
pagerButtonLast.Click += btnLast_Click;
pagerButtonLast.CssClass = "PageEnds";
pnlButtonLast.Controls.Add(pagerButtonLast);
lblPageInfo.Text = string.Format("Showing page {0} of {1}. (total items {2})",
paging.PagedSource.CurrentPageIndex + 1, paging.PagedSource.PageCount,
paging.TotalItems.ToString());
}
Please see my question. In the meanwhile, study this: http://msdn.microsoft.com/en-us/library/ms178472.aspx[^].
You will find all answers if you start from this point.
—SA
这篇关于网页生命周期需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!