Hello Friends,
In my project I wanted to open a new tab on button click.When I click on button second time I need to check if tab is already opened or not.If already opened then focus on that tab else open new tab.
What I have tried:
Below is code snippet which I wrote on button click;
<pre> string TabName = "TestTab";
string url = txturl.Text;
string script = string.Format("window.open('{0}','{1}');", url, TabName);
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"newPage"+UniqueID,script,true);
url : URL which is to be opened in the new tab.
TabName : Setting tab name(purposely)
I tried above code but when I click on button first time it is opening new tab with the tabname but when I click on second time I am passing blank URL with same tabname to focus on that tab.But its not working.
One more thin I noticed is that when I tried in browser console to focus on opened tab with tab name e.g : Tabname.focus it is working. but from code behind it is not.
am I doing something wrong?
Thank you in advanced.