Access input hidden value of a usercontrol in another usercontrol
-
Actually my problem is: there are two usercontrol uc1 and uc2 in uc1 there is a input hidden value which i want to access in uc2 can anyone tell how to access that... I tried with Page.FindControl, Master.FindControl, Master.Master.FindControl but nothing seems to work.... all gives null references.... values is null... Any suggestions is most appreciated...... Please if have any idea do get me posted as early as possible!!
Paritosh Tripathi B.Tech. (C.S.) BrainTechnosys Ltd.
modified on Thursday, April 23, 2009 7:01 AM
-
Actually my problem is: there are two usercontrol uc1 and uc2 in uc1 there is a input hidden value which i want to access in uc2 can anyone tell how to access that... I tried with Page.FindControl, Master.FindControl, Master.Master.FindControl but nothing seems to work.... all gives null references.... values is null... Any suggestions is most appreciated...... Please if have any idea do get me posted as early as possible!!
Paritosh Tripathi B.Tech. (C.S.) BrainTechnosys Ltd.
modified on Thursday, April 23, 2009 7:01 AM
Hi Paritosh, The link below may provide solution for your problem. http://www.dotnetfunda.com/articles/article201.aspx This worked fine for me. Regards, Nyoti
-
Hi Paritosh, The link below may provide solution for your problem. http://www.dotnetfunda.com/articles/article201.aspx This worked fine for me. Regards, Nyoti
Hi Nyoti Thanks for your reply But actually i didn't specified that my page is a dynamic page which is created at runtime and now i want to access a usercontrol's hidden input in other usercontrol. SO the main problem is that page in which the usercontrols are show is dynamic and usercontrols are also dynamically loaded onto the page.
Paritosh Tripathi B.Tech. (C.S.)
-
Hi Nyoti Thanks for your reply But actually i didn't specified that my page is a dynamic page which is created at runtime and now i want to access a usercontrol's hidden input in other usercontrol. SO the main problem is that page in which the usercontrols are show is dynamic and usercontrols are also dynamically loaded onto the page.
Paritosh Tripathi B.Tech. (C.S.)
OK. In this case, you can add dynamic events at the time of Control Creation and write handlers for them.
-
OK. In this case, you can add dynamic events at the time of Control Creation and write handlers for them.
Can elaborate it a bit..... coz i've not done this kinda task before so ifu could explain it with any example would be of grr8 help...
Paritosh Tripathi B.Tech. (C.S.)
-
Can elaborate it a bit..... coz i've not done this kinda task before so ifu could explain it with any example would be of grr8 help...
Paritosh Tripathi B.Tech. (C.S.)
ok. Are you able to execute the events in your user controls? If not, then you need to do something like this. EventInfo SomeEvent = AnyControlInYourUserControl.GetType ().GetEvent("Click"); SomeEvent .AddEventHandler(AnyControlInYourUserControl, new EventHandler( this.AnyControlInYourUserControl_Click)); Write a handler for this. But I think, you are already executing postback, however, since the page is dynamically being created, on post back you are loosing the value of the hidden variable. So in the event handler function above you can store the value of the variable in the session and then can access it. I am sorry, if I misunderstood anything. I will post the code tonight if you want. Thanks, Nyoti
-
ok. Are you able to execute the events in your user controls? If not, then you need to do something like this. EventInfo SomeEvent = AnyControlInYourUserControl.GetType ().GetEvent("Click"); SomeEvent .AddEventHandler(AnyControlInYourUserControl, new EventHandler( this.AnyControlInYourUserControl_Click)); Write a handler for this. But I think, you are already executing postback, however, since the page is dynamically being created, on post back you are loosing the value of the hidden variable. So in the event handler function above you can store the value of the variable in the session and then can access it. I am sorry, if I misunderstood anything. I will post the code tonight if you want. Thanks, Nyoti
Hi Nyoti, No no you've been of grr8 help but actually i'm not able to get the usercontrol i mean the page is dynamic and controls in it are dynamic. Ok i'll explain it .. I've a dynamic page which has a 2 panels in each panel there are usercontrols 1 control shows the articles and other has a review for every article user can post review and that review details are stored in database now problem is when i'm saving the details i need the article id so that i can link the reviews with the articles. i've already taken a input hidden value in which i'm storing articleid in codebehind now i want that article id in the review usercontrol so on submit button click i can save the article id (uniquidentifier) into database along with review details. Hope now you can get exactly what i'm trying to do... Now i want the usercontrol id so i can findcontrol inside it and can find the htmlinputhidden value.. thanks in advance. I'm sure you'll be ready with solution to this problem. Sorry to trouble you so much but really stuck with this problem so favour needed.
Paritosh Tripathi B.Tech. (C.S.)