Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.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/1/asp.net/30.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
如何在html中的“新建”选项卡中单击按钮即可动态打开html文件?_Html_Asp.net_Filestream_Streamwriter_System.io.file - Fatal编程技术网

如何在html中的“新建”选项卡中单击按钮即可动态打开html文件?

如何在html中的“新建”选项卡中单击按钮即可动态打开html文件?,html,asp.net,filestream,streamwriter,system.io.file,Html,Asp.net,Filestream,Streamwriter,System.io.file,我必须创建一个功能,当用户单击按钮时,html文件将在VS中的项目名称中动态生成,然后在新选项卡中打开 我的客户端代码: <asp:button ID="BtnGenrateHTML" runat="server" text=" Generate HTML " OnClick="btnAddnew_Click" /> 您可以将锚定标记的目标属性设置为在新选项卡中打开链接 <a href="abc.html" target="_blank"></a>

我必须创建一个功能,当用户单击按钮时,html文件将在VS中的项目名称中动态生成,然后在新选项卡中打开

我的客户端代码:

 <asp:button  ID="BtnGenrateHTML" runat="server" text="   Generate HTML  " OnClick="btnAddnew_Click"  />

您可以将锚定标记的目标属性设置为在新选项卡中打开链接

<a href="abc.html" target="_blank"></a>

如果在双引号中使用双引号会导致错误,则需要使用反斜杠转义双引号,如下所示

strHTMLGrid= strHTMLGrid + "<a href=\"abc.html\" target=\"_blank\"></a>"; 
strHTMLGrid=strHTMLGrid+”;
编辑该按钮似乎不在abc.html中,您正在尝试在abc.html中添加锚,以打开页面abc.html。这可能不是您想要的。如果您在其他html文件中有按钮,比如test.html,并希望从此打开abc.html,则将按钮更改为anchor,并将其样式表设置为类似于按钮

改变

<asp:button  ID="BtnGenrateHTML" runat="server" text="   Generate HTML  " OnClick="btnAddnew_Click"  />

如果要使用按钮,则可以使用window.open

 <asp:button  ID="BtnGenrateHTML" runat="server" text="   Generate HTML  " 
  OnClick="btnAddnew_Click" OnClientClick="window.open('abc.html', '_blank'); return false;" />

您可以将锚定标记的目标属性设置为在新选项卡中打开链接

<a href="abc.html" target="_blank"></a>

如果在双引号中使用双引号会导致错误,则需要使用反斜杠转义双引号,如下所示

strHTMLGrid= strHTMLGrid + "<a href=\"abc.html\" target=\"_blank\"></a>"; 
strHTMLGrid=strHTMLGrid+”;
编辑该按钮似乎不在abc.html中,您正在尝试在abc.html中添加锚,以打开页面abc.html。这可能不是您想要的。如果您在其他html文件中有按钮,比如test.html,并希望从此打开abc.html,则将按钮更改为anchor,并将其样式表设置为类似于按钮

改变

<asp:button  ID="BtnGenrateHTML" runat="server" text="   Generate HTML  " OnClick="btnAddnew_Click"  />

如果要使用按钮,则可以使用window.open

 <asp:button  ID="BtnGenrateHTML" runat="server" text="   Generate HTML  " 
  OnClick="btnAddnew_Click" OnClientClick="window.open('abc.html', '_blank'); return false;" />

我想你应该把它改成

strHTMLGrid= strHTMLGrid + "<a href='abc.html'>thesitewizard.com</a>"
strHTMLGrid=strHTMLGrid+“”

我想你应该把它改成

strHTMLGrid= strHTMLGrid + "<a href='abc.html'>thesitewizard.com</a>"
strHTMLGrid=strHTMLGrid+“”

strHTMLGrid=strHTMLGrid+“”;这是不工作的Adil点击按钮它只是刷新不做任何事情..他们的任何东西像窗口。打开我们可以写在这里并传递url..这是可能的代码背后..请让我知道。ThanksPage.ClientScript.RegisterStartupScript(This.GetType(),“”,“FNCopup();”,真);在客户端,然后创建了一个函数fncpoup(){window.open('abc.html','u blank');}这对我来说非常有用,但这不会在单击按钮时打开吗?您可以通过绑定按钮上的单击事件在按钮上运行此脚本,如我的回答中所示。strHTMLGrid=strHTMLGrid+“”;这是不工作的Adil点击按钮它只是刷新不做任何事情..他们的任何东西像窗口。打开我们可以写在这里并传递url..这是可能的代码背后..请让我知道。ThanksPage.ClientScript.RegisterStartupScript(This.GetType(),“”,“FNCopup();”,真);在客户端,然后创建了一个函数fncpoup(){window.open('abc.html','u blank');}这对我来说非常有用,但这不会在单击按钮时打开吗?您可以通过绑定我的答案中给出的按钮上的单击事件来在按钮上运行此脚本。Kate感谢您的回复,但此代码刚刚刷新了页面。.是否有任何方法可以在window.open中打开html文件。感谢replyPage.ClientScript.RegisterStartupScript(this.GetType(),“”,“FNCopup();”,true);在客户端,然后制作了一个函数fncopup(){window.open('abc.html','u blank');}这对我来说非常有用,谢谢你的回复–Kate感谢你的回复,但这段代码刚刚刷新了页面..他们有什么方法可以在window.open.replyPage.ClientScript.RegisterStartupScript中打开html文件吗,对);在客户端,然后创建了一个函数fncpoup(){window.open('abc.html','u blank');}这对我来说非常有用,谢谢——