Jump To Right Section
Show
In this post, we want to discuss a nice function to open multiple tabs on button click using c#. Before we get started, if you want to know about customizing web page size with javascript, please go through the following article: Display custom size web form using JavaScript.
You may use the following code/source will open multiple browser tabs on one button click using c#. Don’t forget to change your desire website address at the Button click method.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
protected void btn_Click(object sender, EventArgs e) { int i = 0; String key = "Ahmed"; for (int a = 0; a < 5; a++ ) { i += 1; String URL = string.Format("https://techaid24.com/member_id={0}", i); OpenNewWindow(this, URL, key + i.ToString()); } } |
Multiple tabs or window opener method
1 2 3 4 5 6 7 |
public static void OpenNewWindow(System.Web.UI.Page page, string fullUrl, string key) { string script = "window.open('" + fullUrl + "', '" + key + "', 'status=1,location=1,menubar=1,resizable=1,toolbar=1,scrollbars=1,titlebar=1');"; page.ClientScript.RegisterClientScriptBlock(page.GetType(), key, script, true); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
//Added by Selim for multiple tab Process internetBrowserProcess = new Process(); String websiteUrl = "http://192.168.1.33:8002/ReportViewer.aspx?" + "ReportName=" + rptName; ProcessStartInfo psiOjbect = new ProcessStartInfo(websiteUrl); // You can also use "about:blank". internetBrowserProcess.StartInfo = psiOjbect; internetBrowserProcess.Start(); Thread.Sleep(2000); //Need to wait a little till the slow IE browser opens up. for (int a = 0; a < 5; a++ ) { Process.Start(websiteUrl); } //end for multiple tab |
Open multiple tabs on button click in C#
The article was published on October 21, 2016 @ 11:32 PM
Leave a Comment