473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Another Kind of Eval

Is there a way to have a handle on a control having only the control name
So I dont have to loop through all the controls nested on the form.
checking for the control name = my string
this could be long and heavy on memory

Assuming the control name is "btn_Save"

How to get to ctr being the required control so that I can apply changes
ctr.GetType().GetProperty(oProperty).SetValue( ctr,newVal, null);
Nov 15 '05 #1
2 997
Nicolas,

You are on the right track. Instead of using GetProperty on the Type
instance, use the GetField method on the type containing the control. This
will return the individual fields. Once you have that, you can get an
object that represents the value in the field and get the property on THAT
object, and then set it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

"Nicolas" <nl*****@hotmail.com> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
Is there a way to have a handle on a control having only the control name
So I dont have to loop through all the controls nested on the form.
checking for the control name = my string
this could be long and heavy on memory

Assuming the control name is "btn_Save"

How to get to ctr being the required control so that I can apply changes
ctr.GetType().GetProperty(oProperty).SetValue( ctr,newVal, null);

Nov 15 '05 #2
Thanks but still a bit confuse there
this been my form
button2 been the control that I know the name of
gave me error.
ctr.GetType().GetProperty(oProperty).SetValue( ctr,newVal, null);

this.GetType().GetField("button2").GetType().GetPr operty("BackColor").SetValue(this.GetType().GetFie ld("button2"),Color.Red,null);

Can you help on that syntax?

Thank you.

"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote in message news:%2******************@TK2MSFTNGP12.phx.gbl... Nicolas,

You are on the right track. Instead of using GetProperty on the Type
instance, use the GetField method on the type containing the control. This
will return the individual fields. Once you have that, you can get an
object that represents the value in the field and get the property on THAT
object, and then set it.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

"Nicolas" <nl*****@hotmail.com> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
Is there a way to have a handle on a control having only the control name
So I dont have to loop through all the controls nested on the form.
checking for the control name = my string
this could be long and heavy on memory

Assuming the control name is "btn_Save"

How to get to ctr being the required control so that I can apply changes
ctr.GetType().GetProperty(oProperty).SetValue( ctr,newVal, null);


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
6
by: jochen scheire | last post by:
Is there a way I can calculate a field in a form based on another field in the same form. When clicking submit, both values should be posted to the next page. I want to be able to type in a value...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
11
by: sneill | last post by:
I have read a number of posts on the use of eval() in Javascript, and I agree that its use is questionable. But it does beg the following question: "How arbitrary does a string need to be before...
8
by: Paul Cochrane | last post by:
Hi all, I've got an application that I'm writing that autogenerates python code which I then execute with exec(). I know that this is not the best way to run things, and I'm not 100% sure as to...
2
by: Kent Eilers | last post by:
ok - trying to use eval() to abstract out an update operation i need to perform. I wanted to use the eval() function to avoid HARD CODING the field names that need to be updated in the target...
4
by: sparks | last post by:
1 need to copy the data in one table into another...but its from another database. tables are demographics and testdata database1 database2 demographics personid personid same...
8
by: laredotornado | last post by:
Hi, I want to pass my function myFunc('a', 'b', 'c') as an argument to another function. However, this will not work doStuff('x', 'y', myFunc('a', 'b', 'c'))
3
by: saundra | last post by:
Here is my error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/truthat/public_html/verukasalt/admin/main.php(1) : eval()'d code(1) : eval()'d code(1)...
0
by: Gabriel Rossetti | last post by:
Hello everyone, I'm trying to import some modules into another's namespace (network_utils) network_utils.py: import utils import constants as main_const from services import constants as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.