我不明白的是,我有一个pager_Create函数,是这样的
public void createPager()
{
Div_Pager.Controls.Clear();
ImageButton left = new ImageButton(); left.ID = "leftButton";// +new Random().Next();
left.Click+=new ImageClickEventHandler(pager_Left_Click);
left.ImageUrl = "http://" + Request.ServerVariables["SERVER_NAME"] + ":" + Request.ServerVariables["SERVER_PORT"] + "/Teknik_raporlar/left.bmp";
ImageButton right = new ImageButton(); right.ID = "rightButton";// +new Random().Next();
right.Click+=new ImageClickEventHandler(pager_Right_Click);
right.ImageUrl = "http://" + Request.ServerVariables["SERVER_NAME"] + ":" + Request.ServerVariables["SERVER_PORT"] + "/Teknik_raporlar/right.bmp";
Div_Pager.Controls.Add(left);
Div_Pager.Controls.Add(right);
if (int.Parse(ViewState["NOP"].ToString()) <= 1) // Number of Pages
{
Div_Pager.Visible = false;
}
else
{
Div_Pager.Visible = true;
if (int.Parse(ViewState["CurrentPage"].ToString()) <= 1)
{
left.Visible = false;
}
if (int.Parse(ViewState["CurrentPage"].ToString()) >= int.Parse(ViewState["NOP"].ToString()))
{
right.Visible = false;
}
}
}
protected void pager_Left_Click(object sender, EventArgs e)
{
ViewState["CurrentPage"] = int.Parse(ViewState["CurrentPage"].ToString()) - 1;
}
protected void pager_Right_Click(object sender, EventArgs e)
{
ViewState["CurrentPage"] = int.Parse(ViewState["CurrentPage"].ToString()) + 1;
}
而我不明白的是,这个寻呼机按钮怎么没有触发?我的意思是每次创建寻呼机时我都会创建相同的按钮。那怎么可能。它与页面渲染有什么关系。我的简化代码是这样的:
override Render()
{
function1()
}
Page_Load()
{
function1()
}
funtion1()
{
createpager()
}