Solved

runtime properties

Posted on 2009-05-15
14
150 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
Comment Utility
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
Comment Utility
And get/set  the value as

WebUserControl1.<propertyname>
0
 
LVL 83

Expert Comment

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

Author Comment

by:KaranGupta
Comment Utility
Is the attribute above the property making the difference
0
 

Author Comment

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

will that do
0
 
LVL 83

Expert Comment

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

Author Comment

by:KaranGupta
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
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
Comment Utility
I have declared the attributes as public

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

Expert Comment

by:CodeCruiser
Comment Utility
Have you declared them as properties or just variables?
0
 

Author Comment

by:KaranGupta
Comment Utility

Like that


 public string MTBText

        {

            get;

            set;

        }

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
public string MTBText;
should be enough i think.
0
 

Author Comment

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

Accepted Solution

by:
CodeCruiser earned 500 total points
Comment Utility
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

11 Experts available now in Live!

Get 1:1 Help Now