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);
}
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');
},