我曾嘗試下面如何檢查一般方法中點擊的按鈕?
public partial class PaymentSearch : System.Web.UI.Page
{
private bool button1WasClicked = false;
protected void linkToday_Click(object sender, EventArgs e)
{
button1WasClicked = true;
}
protected void ddlRecordPayment_SelectedIndexChanged(object sender, EventArgs e)
{
gridAllPaymentBind(1);
}
public void gridAllPaymentBind(int pageIndex)
{
if (button1WasClicked == true)
{
result = 3;
command.Parameters.AddWithValue("@result", result);
}
}
但在「button1WasClicked」讓我在那裏alredy下拉列表改變事件火中單擊鏈接按鈕假值「gridAllPaymentBind」梅索德。
最好在會話中放置該布爾值。 –
您是否在單擊時檢查linkToday_Click方法是否被調用? –
把'private bool button1WasClicked = false;'在'Page.IsPostPack'內檢查,因爲每當頁面回傳值改變爲false時 –