問題
使用 ButtonFiled 實作Javascript開啟視窗
解決方法
在GridView上點擊ButtonFiled時,都會觸發GridView的RowCommand事件,因此可以在CommandName裡加上特定的flag,去判斷此次觸發的是哪一個Button
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string strJavaScript = string.Empty;
if (e.CommandName == "Print")
{
strJavaScript = @"<script language=Javascript>window.open('../Confirm/PrintConfirm.aspx' );</script>";
}
else if (e.CommandName == "Exchange")
{
strJavaScript = string.Format(@"<script language=Javascript>window.open('../B2CInvoice/BingoPrintConfirm.aspx?invoiceNumber={0}&type={1}','確認視窗','height=150,width=350,top=300,left=300,toolbar=no,menubar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no');</script>", Number, "Exchange");
}
Response.Write(strJavaScript);
}
沒有留言:
張貼留言