在我的Asp.Net(C#)网页中,我从Jquery Ajax做了95%的工作。只有打印工作是从服务器端代码发生的,因为它需要重定向另一页进行打印。这里是我的打印按钮的代码是否有可能在asp.net C#中的静态方法中使用RegisterClientScriptBlock?
protected void btnprint_Click(object sender, ImageClickEventArgs e)
{
string status = "Normal";
string Id = txtReceiptNo.Text;
string BillType = "BillReceipt";
string Url = "BillReceipt.aspx";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ApprovalHistory", "window.open('BillReceiptReport.aspx?Id=" + Id + "&Status=" + status + "&BillType=" + BillType + "&Url=" + Url + "', '_blank');", true);
}
当我点击打印按钮将其重定向与另一个选项卡中的一些价值观的PrintPage。
但问题是,当我点击打印按钮回发发生和一切扰乱我的网页,因为如上所述,我正在做95%的工作使用JQuery的Ajax。
所以我决定从jQuery的阿贾克斯做100%的工作,并试图调用内部静态该打印功能,但的WebMethod我发现的RegisterClientScriptBlock没有内部静态方法工作。我试图做这样的事情......
[WebMethod]
public static void PrintReport()
{
string status = "Normal";
string Id = "40";
string BillType = "BillReceipt";
string Url = "BillReceipt.aspx";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ApprovalHistory", "window.open('BillReceiptReport.aspx?Id=" + Id + "&Status=" + status + "&BillType=" + BillType + "&Url=" + Url + "', '_blank');", true);
}
请帮我家伙....
只是尝试通过添加此行'page.ClientScript.RegisterStartupScript(“ApprovalHistory”,“”);' –
您好@Satindersingh感谢您的评论,但'page.ClientScript'是不是在静态方法工作 –