0
我不明白的是,我有一個pager_Create功能,它就是這樣Asp.net pager單擊事件不會觸發,它背後的邏輯是什麼?
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()
}