我想調用一個函數javascript函數來打印表單,代碼後面的打印按鈕click.I m首先隱藏我的gridview的一列,然後我想打印它。調用javascript函數從代碼後面打印表格
protected void btnPrint_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in grdTransaction.Rows)
{
if (UType == "A")
{
grdTransaction.Columns[7].Visible = false;
}
else
{
grdTransaction.Columns[3].ItemStyle.Width = 100;
grdTransaction.Columns[5].Visible = false;
}
}
}
我已經使用
1) ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script",
"<script type='text/javascript'>clicked('printablediv');</script>", true);
2) ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script",
"clicked('printablediv');", true);
3) btnPrint.Attributea.Add("onclick","clicked('printablediv');");
4) btnPrint.Attributea.Add("onclick","return clicked('printablediv');");
以上所有選項沒有工作,但的OnClientClick事件它works..Please幫助我。 在此先感謝。