Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

runtime properties

Posted on 2009-05-15
14
Medium Priority
?
168 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

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
 
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 2000 total points
ID: 24394029
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Screencast - Getting to Know the Pipeline
Suggested Courses

885 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