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

UserControl Ajax Example problem

4 Answers 160 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Neal
Top achievements
Rank 1
Neal asked on 19 May 2008, 02:37 PM

Hi,

Based on your example.. of dynamically loading UserControls:
 
if (LatestLoadedControlName == "~/Forms/LoginAuth/LoginCS.ascx")

{

//Ajaxify the DropDownList in the UserControl itself

//Get the WebUserControl

UserControl MyControl = (UserControl)Page.FindControl(LatestLoadedControlName);

/Get user control's button and label

DropDownList MyDDL = (DropDownList)MyControl.FindControl("DropDownList1");

Button LoginBtn = (Button)MyControl.FindControl("btnLogin");

//Add the necessary AJAX setting programmatically

RadAjaxManager1.AjaxSettings.AddAjaxSetting(MyDDL, null);

}

My Dynamically loaded UserControl Loads ok, ..but when trying to find it...i.e.  
1)  Page.FindControl("~/Forms/LoginAuth/LoginCS.ascx")
2)  Page.FindControl("~/Forms/LoginAuth/LoginCS")
3) Page.FindControl("LoginCS.ascx")
4)  Page.FindControl("LoginCS")

MyControl =  null  (Your example..makes no use of folders,..guess thats the issue,...???)
I tried dragging the Login uCtl onto the main form,..and still Page.FindControl can't find it.

and the Page.Forms coll when in debug, shows 1 entry, and that being it's form.

TIA
Neal

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 19 May 2008, 03:53 PM
Hello Neal,

The loaduser controls help article is added only to aid people who are not sure how to dynamically load user controls. It is not in any way specific for loading usercontrols that are going to contain ajaxified controls. Please remove all ajax functionality, make the user controls load properly with standard postbacks and after that you can ajaxify it. If having problems with the latter, we would gladly help you.

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Neal
Top achievements
Rank 1
answered on 20 May 2008, 08:21 AM
Hi,

I got around the initial problem of "MyControl" remaining Null.
by changing the "Page.FindControl to ContentPane.FindControl and
stripping out the "/"  and "~" first from MyControlId

New Problem however.

My "Defualt Page"  (LeftNavPane+Menu  and ContentPane), loads the login UserCtl fine,..and I use
RadAjaxManager1.AjaxSettings.AddAjaxSetting(LoginBtn, this, LoadingPanel1);





also

RadAjaxManager1.AjaxSettings.AddAjaxSetting(LoginBtn, MyUserCtl, LoadingPanel1);

to Ajaxify the LoginBtn on the Login.ascx, expecting the Login.ascx to postback, and set the blnLogged value  (and the Default Main pages Logged property in  ViewState ,
but the postback is on the PageLoad of the Default.aspx, where-after it fires the postback on the Login.ascx usercontrol ,
and then thats where it stops,..Leaving the login user control visible on the ContentPane.
 
Am I supposed to Clear the Defualt form's ContentPane from the UserCtl (and set it's ViewState Logged property from there??

TIA
Neal

0
Steve
Telerik team
answered on 20 May 2008, 11:44 AM
Hello Neal,

Is this in this context the page (user control)? Note that you cannot ajaxify a whole page by adding it as updated control, neither you can ajaxify controls that do not render any html (user control for example). As this help article shows, clearing the parent where you load the user controls is necessary.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Neal
Top achievements
Rank 1
answered on 20 May 2008, 02:33 PM
Thanks Steve,

I think the problem I'm having is I use RadPanes in the Parent Page  (Default.aspx)
(based on the simple example of loading pages into a content pane)
ParentPage has 
NavPane and ContentPane
and then as you pointed out trying to Ajaxify the UserCtl )("Login.ascx"), (which I created from a login.aspx)
and not it's login button (btnLogin)

and
not using the ResolveUpdatedControls.
That example may help a lot.

Is it better then to remove the RadPanes from the Parent page altogether?
(I have had some success so far, in that both pages (Parent and UserCtl postback but  I can't get the parent to set its "Logged" viewState Property to True.

I will try the ResolveUpdatedControls.,..and asp:panels

thanks
Neal
Tags
Ajax
Asked by
Neal
Top achievements
Rank 1
Answers by
Steve
Telerik team
Neal
Top achievements
Rank 1
Share this question
or