473,836 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hooking into a getter or setter of .Net class

Hi,

Is there anyway that I can hook into a getter and setter of a property for a
..Net control across my application? Specifically, what I'd like to do is
execute some code whenever a System.Web.UI.W ebControls.Text Box.Text property
is set'd or get'd. I'm aware there are things I can do such as wrap this
control, but for political reasons, I need to try to come up with a solution
that will involve changing or adding as little code as possible.

I am using .Net 3.5, so if there was this kind of functionality added that
would allow this, as it's similar to extension methods, I'd be able to use
that.

Thanks
Aug 8 '08 #1
2 3121
You need to use notification events really; you can't (without some
*major* hacking, i.e. pretending to be a debugger) just link into
arbitraty code. Fortunately, there is a TextChanged event you can
subscribe to.

If you want to apply this to all controls, you'd probably have to
override one of the init methods in ASP.NET to search (recursively)
for TextBox controls and subscribe to the event. I can't tell you
which init method to override as I'm not an ASP.NET expert, but try an
ASP.NET forum?

Marc
Aug 8 '08 #2
Marc Gravell wrote:
You need to use notification events really; you can't (without some
*major* hacking, i.e. pretending to be a debugger) just link into
arbitraty code. Fortunately, there is a TextChanged event you can
subscribe to.
Or use an aspect-oriented programming (AOP) weaving tool, which will
automatically modify the IL after compilation.
>
If you want to apply this to all controls, you'd probably have to
override one of the init methods in ASP.NET to search (recursively)
for TextBox controls and subscribe to the event. I can't tell you
which init method to override as I'm not an ASP.NET expert, but try an
ASP.NET forum?

Marc

Aug 8 '08 #3

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

Similar topics

3
18092
by: Kiwi | last post by:
Hello. I know a getter can return other thing than a field. I know a setter can do more things than setting a field. I know there are "setter only" cases and "getter only" cases. I do use getters and setters when needed. But most of getter/setter pairs I have seen are just like below; > private int x; > public int getX() { return x; } > public void setX(int x) { this.x = x; }
4
5545
by: Jimbo | last post by:
I am sort of new to C#. Currently have a private property called "_name" in a class. I have written a public getter and setter routine for it called "Name". Currently, the getter for the property does some data manipulation before it returns the value. I wanted to add another getter to this property that would returnt the "Raw" value (what is stored in _name). Example:
1
1926
by: Steve | last post by:
I generate C# webservices proxy code from WSDL file, it turns out the classes generated have public member variables and no getter/setter methods as follows, and I am able to get data when running the client. public class MyFeeResponse {
12
3745
by: Adam Sandler | last post by:
Hi all, I hope this is an easy one... Using VWD 2005. When I call my accessor method (getName) I always receive an empty string back. Debugging shows there should be something there but I cannot figure out where the problem is actually occurring. The first couple of lines of my code behind: Partial Class _Default
6
3516
by: Peter Franks | last post by:
Is it possible to deserialize a class that has a public property w/ a setter, but no getter? I'm not finding anything that would allow this -- Presuming that is is NOT possible, what are the best practices for implementing versioning for changing properties? Thanks
3
99397
by: Martin Pöpping | last post by:
Hello, I´m coming from the Java World. Here Programmers often use (like in C++?) getter and setter methods. F.e.: class Mirror{ private int width_;
2
1411
by: Amie | last post by:
Hi, I have an atlas related question.. I have a web form that submits the information to a web service method, and it's done thru Atlas by binding the web methods to client functions. It seems to be working fine, except for when the class has a property with only getter (no setter), it freaks out, and returns the following
5
2517
by: javatech007 | last post by:
Hi, I've been at this question all day and still just don't know what to do. It's the last of all the questions I have to do and can't figure it out!! If anyone could help or give guidance it would be greatly appreciated!! Question: Write a class called shapes that accepts two variables into its constructor called a and b. Along with the getter and setter methods required, write a method called toPrinter() to output the coordinates of...
1
5204
by: mk | last post by:
It seems like getter is defined in such way that it passes only 'self': class FunDict(dict): def __init__(self): self.fundict = dict() def fget(self, fun): return fundict
0
9810
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10526
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10567
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10237
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6972
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5641
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4437
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3100
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.