Solved

runtime properties

Posted on 2009-05-15
14
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET data base connection 35 95
powershell try catch  and $ErrorActionPreference = continue 6 71
CSS question 16 63
Left aligned $ and right aligned amount ASP.NET 7 44
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…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 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