Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.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
将asp.net添加到html页面_Html_Asp.net_Add - Fatal编程技术网

将asp.net添加到html页面

将asp.net添加到html页面,html,asp.net,add,Html,Asp.net,Add,首先感谢你阅读我的问题 我想把代码2变成代码1。。。任何人都可以帮助我 代码1是普通的HTML页面 code 1: <table> <tr> <td> //I want to add code 2 here.. </td> </tr> </table> code 2: if(System.IO.File.Exists(ConfigurationManager.AppSetti

首先感谢你阅读我的问题

我想把代码2变成代码1。。。任何人都可以帮助我

代码1是普通的HTML页面

code 1:

<table>
  <tr>
    <td>
        //I want to add code 2 here..
    </td>
  </tr>
</table>



code 2:

if(System.IO.File.Exists(ConfigurationManager.AppSettings["DBCache"].ToString()+"Frame.xml"))
{
   //something
} 
代码1:
//我想在这里添加代码2。。
代码2:
如果(System.IO.File.Exists(ConfigurationManager.AppSettings[“DBCache”].ToString()+“Frame.xml”))
{
//某物
} 

它应该类似于以下内容:

 <table>
      <tr>
        <td>
             <% if(your condition)
               {%>

              <% } %>
        </td>
      </tr>
    </table>

它应该类似于以下内容:

 <table>
      <tr>
        <td>
             <% if(your condition)
               {%>

              <% } %>
        </td>
      </tr>
    </table>

我已经有一段时间没有使用ASP.NET页面了。试试这个:

<script runat="server">
    if (System.IO.File.Exists(ConfigurationManager.AppSettings["DBCache"].ToString()+"Frame.xml")) {
        myLiteral.Text="Welcome to ASP.NET!!";
    }
</script>

<table>
  <tr>
    <td>
        <asp:Literal id="myLiteral" runat="server" />
    </td>
  </tr>
</table>

如果(System.IO.File.Exists(ConfigurationManager.AppSettings[“DBCache”].ToString()+“Frame.xml”)){
myLiteral.Text=“欢迎使用ASP.NET!!”;
}

我已经有一段时间没有使用ASP.NET页面了。试试这个:

<script runat="server">
    if (System.IO.File.Exists(ConfigurationManager.AppSettings["DBCache"].ToString()+"Frame.xml")) {
        myLiteral.Text="Welcome to ASP.NET!!";
    }
</script>

<table>
  <tr>
    <td>
        <asp:Literal id="myLiteral" runat="server" />
    </td>
  </tr>
</table>

如果(System.IO.File.Exists(ConfigurationManager.AppSettings[“DBCache”].ToString()+“Frame.xml”)){
myLiteral.Text=“欢迎使用ASP.NET!!”;
}
这样就可以了

<%@ Page Title="YourPage" Language="C#" %>
<table>
  <tr>
    <td>
        <% 
        if(System.IO.File.Exists(ConfigurationManager.AppSettings["DBCache"].ToString()+"Frame.xml")) {

        }
        %>
    </td>
  </tr>
</table>

这样就可以了

<%@ Page Title="YourPage" Language="C#" %>
<table>
  <tr>
    <td>
        <% 
        if(System.IO.File.Exists(ConfigurationManager.AppSettings["DBCache"].ToString()+"Frame.xml")) {

        }
        %>
    </td>
  </tr>
</table>



您可以在HTML页面上使用ASP控件吗?例如:?是否可以将代码2添加到代码1@A您能在HTML页面上使用ASP控件吗?例如:?是否可以将代码2添加到代码1@谢谢你的回复@Irfan TahirKheli。但是我在html页面的输出中得到了代码2…没问题。。我想你接受的答案和我的答案是一样的:p@lllayaThanks,谢谢你的回复@Irfan TahirKheli。但是我在html页面的输出中得到了代码2…没问题。。我想你接受的答案和我的答案是一样的:p@lllayaalso,将你的文件重命名为yourfile.aspx!:)谢谢@Lars Anundskas。但我得到的是“对象引用未设置为对象的实例”。if(System.IO.File.Exists(ConfigurationManager.AppSettings[“DBCache”].ToString()+“Frame.xml”))中的错误。密钥DBCache是否存在于您的AppSettings中?它位于remote@Lars Anundskasplease explain,“in remote”?另外,将您的文件重命名为yourfile.aspx:)谢谢@Lars Anundskas。但我得到的是“对象引用未设置为对象的实例”。if(System.IO.File.Exists(ConfigurationManager.AppSettings[“DBCache”].ToString()+“Frame.xml”)中的错误。密钥DBCache是否存在于您的AppSettings中?它在remote@Lars Anundskasplease explain,“in remote”?哈哈,它正在工作。谢谢@AntHa,它正在工作。谢谢@Ant