在我的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'是不是在靜態方法工作 –