Reputation: 1545
I need to open 2 different pages in different tab on click of save button. In the button click event I have the below code. The code is working if there is only one script block. Tried appending the scripts together. That is also not working
string voucher= CreateVouchers(startDate, endDate, userID);
UcErr.GeneralMessage = "Submitted successfully.";
if (voucher== ""){
if (ddlLeaveType.SelectedValue == "1")
{
pageURL = "http://" + baseURL + "HR/Report1.aspx?LeaveID=" + LeaveID;
string script = "window.open('" + pageURL + "' ,'_blank');";
ScriptManager.RegisterClientScriptBlock(this,this.GetType(), "tab1", script, true);
}
string pageURLNew = "http://" + baseURL + "HR/Print1.aspx?LeaveID=" + LeaveID;
string scriptNew = "window.open('" + pageURLNew + "' ,'_blank')";
ScriptManager.RegisterClientScriptBlock(this,this.GetType(), "tab2", scriptNew, true);
}
Upvotes: 0
Views: 189
Reputation: 1545
As my save click function contains different function calls, RegisterClientScriptBlock is not working. So I resolved the issue using a jquery function
Added a div in aspx page
<div runat="server" ID="JSCall"></div>
In the save button click
JSCall.InnerHtml = "<div class='ajaxJavaScriptCall'>hr.DisplayDetails(" + ID + ");</div>";
In js
DisplayLeaveDetails: function (leaveID) {
window.open('/HR/Report1.aspx?LeaveID=' + leaveID, '_blank');
window.open('/HR/Print1.aspx?LeaveID=' + leaveID, '_blank');
},
Upvotes: 0
Reputation: 666
**You can also append the urls and use it in single
ScriptManager.RegisterClientScriptBlock
Try this**
This also worked for me , I tried in updatepanel also
string voucher= CreateVouchers(startDate, endDate, userID);
UcErr.GeneralMessage = "Submitted successfully.";
string script="";
if (voucher== ""){
if (ddlLeaveType.SelectedValue == "1")
{
pageURL = "http://" + baseURL + "HR/Report1.aspx?LeaveID=" + LeaveID;
script = "window.open('" + pageURL + "' ,'_blank');";
//ScriptManager.RegisterClientScriptBlock(this,this.GetType(), "tab1", script, true);
}
string pageURLNew = "http://" + baseURL + "HR/Print1.aspx?LeaveID=" + LeaveID;
string scriptNew = "window.open('" + pageURLNew + "' ,'_blank');";
ScriptManager.RegisterClientScriptBlock(this,this.GetType(), "tab2", script+""+scriptNew, true);
}
Upvotes: 0