[英]Asp.net get variable from C# code
我想在ASP代碼中使用繼承的變量
我的代碼看起來像這樣
namespace WebApplication2
{
public class Global : System.Web.HttpApplication
{
public bool abcdef = true; // my variable that i want to use in my asp code
...
}
}
ASP部分如下所示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<%
if(webapplication1.main.abcdef) //this is incorrect, i want to correct that
{%>
my first web page
<%}
else
{%>
my second web page
<%} %>
</html>
如何在我的ASP代碼中使用變量abcdef
?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" MasterPageFile="MasterPage.Master"
Inherits="Namespace.YouClass" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script>
if(<%#this.abcdef%>)
{
//do your work
}
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.