This is a migrated thread and some comments may be shown as answers.

Update usercontrol from another usercontrol

4 Answers 194 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 31 Jul 2012, 07:35 AM
Hi,

I have a page with no masterpage which has two usercontrols. One user control has a form which submits the information and another with a grid which displays the information.

I want to be able to submit the form and update the information in other usercontrol:

default.asp
--->Usercontrol1
----------->Form with submit button

---Usercontrol2
----------->RadGrid


I've been looking at the below article but get object reference error
http://www.telerik.com/help/aspnet-ajax/ajax-user-controls.html


Do I have to add any additional code for this to work.

Thanks

4 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 02 Aug 2012, 11:34 AM
Hello Karl,

The code provided in the mentioned help topic works correctly in a sample scenarios on my end. Could you please share your page markup as well as the related code behind. Thus we will be able to inspect the code locally and advise you further.

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Karl
Top achievements
Rank 1
answered on 02 Aug 2012, 03:37 PM
Hi,

I've removed the code but willy try again. I will expand on the detail alittle further.:
default.aspx (RadAjaxManager)
--->Usercontrol1
------>AjaxPanel
----------->Form with submit button

---Usercontrol2
------>AjaxPanel
----------->RadGrid
Looking at the below link below I did this:

UserControl MyControl1 = (UserControl)Page.FindControl("WebUserControl1");
UserControl MyControl2 = (UserControl)Page.FindControl("WebUserControl2");


    //Get user control's button and label
    Button MyButton = (Button)MyControl1.FindControl("Button1");
    RadGrid MyGrid = (RadGrid)MyControl2.FindControl("Label1");
 

    //Add the necessary AJAX setting programmatically
    RadAjaxManager1.AjaxSettings.AddAjaxSetting(MyButton, MyGrid);

Is this correct?

Update, it appears that the ajax is working, but the grid is not reloading, on the button in mycontrol1 I used find control to to get the grid and then did rebind but it appears not to refresh.

How can I get the grid to rebind?

Thanks

0
Karl
Top achievements
Rank 1
answered on 03 Aug 2012, 12:22 PM
I left response writes to check if they were finding the controls, all works now.

Thanks
0
Maria Ilieva
Telerik team
answered on 06 Aug 2012, 02:30 PM
Hi,

I'm glad that you have mentioned to fix the issue on your end. Do not hesitate to contact us back if any issues with RadControl arise in future.

Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Ajax
Asked by
Karl
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Karl
Top achievements
Rank 1
Share this question
or