How to open multiple new windows in one click with querystring using ASP.NET and Javascript

Put this Javascript on the designer.
<script language=”javascript” type=”text/javascript”>
   
    function OpenNewWindow() {
     Use this one,
    val = document.getElementById(“ctl00_ContentPlaceHolder1_HiddenField1″).value;
 or this one,
    val = document.getElementById(‘<%=HiddenField1.ClientID %>’).value;
    
    ID = val;
    
    if (val == ”)
    {
        alert(‘Message Here.’);
    }
    else
    {
        IDArray = ID.split(“,”);
        for (ctr=0; ctr<IDArray.length; ctr++)
        {
            window.open(‘WebForm.aspx?ID=’ + IDArray[ctr], IDArray[ctr], ‘resizable=no, status=1, scrollbars=1 width=640, height=480’)
        }        
    }
}
</script>
 
Put this code on form load event,
            Button1.Attributes.Add(“onClick”, “OpenNewWindow()”);
 
Put this code on form load (outside of !Page.IsPostBack)  event, and on all three dropdownlist event Two Buttons Include All and Exclude All Click Event.
            MethodName();
 
Create a Checkbox name it checkbox1. Create a hiddenField name it ID. Create a method name it MethodName.
    private void MethodName()
    {
        string inv = “”;
        for (int iCount = 0; iCount < GridView1.Rows.Count; iCount++)
        {
            CheckBox cb = (CheckBox)GridView1.Rows[iCount].Cells[0].FindControl(“checkbox1“);
            if (cb.Checked)
            {
                hidden = (HiddenField)GridView1.Rows[iCount].Cells[0].FindControl(“ID“);
                if (inv.Trim() != “”)
                {
                    inv += “,” + hidden.Value;
                }
                else
                {
                    inv = hidden.Value;
                }
            }
        }
        HiddenField1.Value = inv;
    }
Ask Medel Antiporta for any further inquiries.

 

Advertisements
This entry was posted in ASP.NET 2 and JavaScript. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s