I want use variables from inherits in asp code
My code looks like that
namespace WebApplication2
{
public class Global : System.Web.HttpApplication
{
public bool abcdef = true; // my variable that i want to use in my asp code
...
}
}
ASP part looks like below:
<!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>
How can I use my variable abcdef
in my asp code?
<%@ 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.