Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 同时打开新选项卡和加载当前选项卡_C#_Asp.net_Button - Fatal编程技术网

C# 同时打开新选项卡和加载当前选项卡

C# 同时打开新选项卡和加载当前选项卡,c#,asp.net,button,C#,Asp.net,Button,我的雇主要求我创建一个功能,点击后,它会在“新建”选项卡上打开一个新站点,但同时当前页面完成加载或加载到其他页面。恐怕我只有伪代码要显示,因为我认为这是一个技术问题,而不是编码问题 protected void btnProceed_Click(object sender, EventArgs e){ //Some logics with some post and get process. //generate URL //Redirect to an external page in a

我的雇主要求我创建一个功能,点击后,它会在“新建”选项卡上打开一个新站点,但同时当前页面完成加载或加载到其他页面。恐怕我只有伪代码要显示,因为我认为这是一个技术问题,而不是编码问题

protected void btnProceed_Click(object sender, EventArgs e){
//Some logics with some post and get process.

//generate URL

//Redirect to an external page in a new tab.
//At the same time current page undergo UI changes or redirecting to other page.}

但是,当页面重定向到外部页面时,它将不再读取其下方的任何内容。

这可能很简单,只需使用JavaScript打开一个新窗口并在同一函数中刷新当前窗口即可

<button onclick="OpenAndReload()">Open & Reload</button>

<script>
    function OpenAndReload() {
        window.open('https://www.google.nl');
        location.reload();
    }
</script>

非常感谢,这很有效。这似乎是回应。重定向完全停止了一切,甚至这个脚本。所以我必须找到另一种方法,添加一个脚本重定向到新页面。你的回答帮我找到了正确的方向。
protected void btnProceed_Click(object sender, EventArgs e) {
    //your code

    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "OpenWindow", "window.open('https://www.google.nl');", true);
}