Passing values between Custom controls?

A

Arulraja

Hello,
Is there a way to pass a value between custom Controls?

I created 2 custom Controls. Both of them render a HTML table.The
First control's tablecell has the second control on it. The Second
controls tablecell has a Button on it.

Is there a way to read the value(Cell Value) of the second control
from the first control.


Also, the second control has a button, in the click event I do some
validation and set the Hidden control, but after the event it fires
the first control Createchildcontrol method, then second control's
createchildcontrol method, in this time it losses the value which I
set during the onClick event.

Is there anyway I have maintain the state of the child control?
Also, Is there a way to read the value using javascript from the
client side?
Actually I am assinging the control ID property for all the controls,
but because of the INamingcontainer, it assign's a new unique ID. If I
remove the Inamingcontainer, the click event is not firing.

Can somebody help me on this.

Thanks
Arul
 
V

Victor Garcia Aprea [MVP]

Hi Arulraja,
You should persist the state of your custom properties into the viewstate.
If you're interested in a TableCell's properties this class already persists
its properties states into viewstate.
client side?
Sure, you could write some javascript code to query an element's attributes
for example, it will much depend on how you output this value from the
server-side.
but because of the INamingcontainer, it assign's a new unique ID. If I
remove the Inamingcontainer, the click event is not firing.
What you're seeing is okay. If you're writing a composite control you need
to implement the INamingContainer marker interface. If you need to output
javascript from your server-side control you don't have to guess the IDs,
you could use the ClientID property instead, which is the ID that is going
down to the browser.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top