我想调用一个函数javascript函数来从打印按钮单击后面的代码中打印表单。我首先将我的gridview的一列隐藏在表单上,然后我想打印它。
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事件上有效。请帮帮我。提前致谢。