Solved

runtime properties

Posted on 2009-05-15
14
152 Views
Last Modified: 2013-11-08
Hi

I am making a custom webcontrols in which I have defined some properties

I want user can access some properties in code behind rather than .aspx

Is that possible

0
Comment
Question by:KaranGupta
  • 6
  • 6
  • 2
14 Comments
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24393653
You can do like this.

[
       Description("<description>"),
       Category("<category>")
    ]
    public bool <propertyname>
    {
        get
        {
            object o = ViewState["<variable>"];
            return (o == null) ? false : (bool)o;
        }
        set
        {
            ViewState["<variable>"] = value;
        }
    }
0
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24393658
And get/set  the value as

WebUserControl1.<propertyname>
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24393662
Not the best description but yes properties can be accessed in code behind.
0
 

Author Comment

by:KaranGupta
ID: 24393665
Is the attribute above the property making the difference
0
 

Author Comment

by:KaranGupta
ID: 24393682
But I don't want to access it at .aspx page

will that do
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24393729
Please provide more description mate. I am not very good at reading minds of people.
0
 

Author Comment

by:KaranGupta
ID: 24393832
Hi CodeCruiser

I have a webserver custom control

And I am using the dll in some other project

In the custom control I have defined some properties of the control

When you use the control on the webpage you can access the properties.

Say I  have defined the property MTBText what I want is I should not use this propety in .aspx page

like

<FTB:MultiPurposeTextControl  id="test"  MTBText="abc"/>

but I should use it in code behind
like
test.MTBText = "abc";

I hope I am clear with my point now
If you still need any explanation

Please donot hesitate to ask me
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24393919
What if you just declare such properties as public variables within the class instead of declaring them as properties using attributes?
0
 

Author Comment

by:KaranGupta
ID: 24393931
I have declared the attributes as public

but still I can use it in .aspx file
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24393965
Have you declared them as properties or just variables?
0
 

Author Comment

by:KaranGupta
ID: 24393970

Like that


 public string MTBText

        {

            get;

            set;

        }

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24393976
public string MTBText;
should be enough i think.
0
 

Author Comment

by:KaranGupta
ID: 24393990
still it is coming as a property in .aspx page
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24394029
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now