views:

582

answers:

1

hie guys.

I have ParentPage which contains 4 user controls and i have user dropdown on each control. whenever i change the selected index .. all user control should populate according to the selected value of user. Can anyone kindly tell me.. how to pass the values to different usercontrol at same time ... Thanks !!!!!

+2  A: 

You could create a UserControl base class with the common properties. The properties would need to wrap a session variable, which would be common to each.

eg:

public string Text
        {
            get
            {
                if (Session["UserControlText"] == null || Session["UserControlText"].ToString().Trim() == String.Empty)
                {
                    Session["UserControlText"] = String.Empty;
                }

                return Session["UserControlText"].ToString().Trim();
            }
            set
            {
                Session["UserControlText"] = value;
            }
        }
Mark Redman
assuming you're posting back each time? If you need to do this on the client, have a look at the jQuery javascript library.
Mark Redman
What's JQuery got to do with passing variables through? If that's all the use you're going to put JQuery to then better use simple Javascript instead.
Cyril Gupta
Using jQuery is just a suggestion for a good javascript library that makes implementing cross platform javascript a lot easier, sure simple javascript can be used.
Mark Redman
@@MarkIs there any other way , other than using session..is it possible to pass property value from one usercontrol to another ???
Monu
@@Mark yeah i'm posting back each time and fetching data from DB according to that fill all the usercontrols again !!
Monu
If you're posting back each time, can you not just read the component/form element values from one control to use for the other controls? If you do this, use ViewState instead of Session in the base class in the code above (this will keep the individual values for each control separate)
Mark Redman
thanks marks for ur suggestion :) !!
Monu