In bleow code Page
is opening in a new window. My requirement is to open it in a new tab.
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup",
"window.open('" + strFilePath + "','_blank')", true);
In bleow code Page
is opening in a new window. My requirement is to open it in a new tab.
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup",
"window.open('" + strFilePath + "','_blank')", true);
You can't open a new tab because that's up to the browser to decide. The user can configure his browser to open a new window on a separate tab. In the latter case, your code will work.
If you want the user to have a windows opened in a new tab, you can only display a link and have the user, right click it, etc.
Note, that clicking a link can still cause a postback on the current page.
You'll just use a redirection on your postback.
Never waste your effort controlling client environment, I have done it many times, may be disabling right click or opening in new window, and finally had to live up with client settings for my code or hack to work the way I expected it to.
In the mean time have a look at :-
Open a URL in a new tab (and not a new window) using JavaScript