skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

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

  2. **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);
    }
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search