Access struct member on ascx

N

nets

I have a struct...
namespace Test.Web.UserControls
{
public struct StructTest
{
public const int PageBorder = 0;
....

And I'm trying to use it in a ".ascx" file:

<%@ Control Language="c#" Codebehind="Header.ascx.cs"
AutoEventWireup="false" Inherits="GSS.Web.UserControls.Header"%>
....
<table width="100%" height="100%" cellspacing="0" cellpadding="0"
border="<%=StructTest.PageBorder %>">

....

I can access "StructTest.PageBorder" in Page_Load on the ".ascx.cs" file,
but not in the ".ascx" file.
Any clues?

Thanks!
-nets
 
A

Ashish Kaila

You cannot access fields statically. Try creating an object and using fields
from object. i.e.
StructTest a = new StructTest();
a.PageBorder = ...
Ashish
 
N

nets

This makes sense, but... I am using a "const" and following did work in the
..ascx.cs file:

int a = StructTest.PageBorder;

Sorry for such basic questions, I am really new to c#.

Thanks!
-sten
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top