473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Access struct member on ascx

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

Nov 16 '05 #1
2 1471
You cannot access fields statically. Try creating an object and using fields
from object. i.e.
StructTest a = new StructTest();
a.PageBorder = ...
Ashish

"nets" <no*@here.com> wrote in message
news:Og**************@tk2msftngp13.phx.gbl...
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

Nov 16 '05 #2
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

"Ashish Kaila" <so*****@microsoft.com> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
You cannot access fields statically. Try creating an object and using fields from object. i.e.
StructTest a = new StructTest();
a.PageBorder = ...
Ashish

"nets" <no*@here.com> wrote in message
news:Og**************@tk2msftngp13.phx.gbl...
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


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Richard Webb | last post by:
Hi all, I guess this is more of a design problem than a language problem, but I'm confused either way! I have a class and it has a private data member which is a struct. The size of the struct is...
7
by: Kristoffer Arfvidson | last post by:
HI! I have a little question... I need to access a usercontrol (*.ascx) file that is located outside my application directory of my dll... Heres my paths on my server: wwwroot/ --------------...
3
by: Wayne Brantley | last post by:
VS2005 RTM Create a web user control to use as a base class for other web user controls. Now, create a new web user control, change the class it inherits from to your base class and compile....
8
by: rn5a | last post by:
I have a user control named Enter.ascx which has 2 TextBoxes. The 2 TextBoxes are named txt1 & txt2. The entire logic of this user control (like the properties of the 2 TextBoxes using set/get...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.