Solved

runtime properties

Posted on 2009-05-15
14
159 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AJAX ModalPopupExtender will Not Hide in Asp.net 1 32
asp web application 3 36
reading excel file in .net 2 30
Securing WEBAPI on Azure 2 19
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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

685 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