Hi
I have a web site which makes extensive use of Telerik controls
In my current site, I have navigation to various user controls
which already exist declaratively on the page (I just make them visible as required)...
I am changing this so that the User Controls are "loaded as required".
For example in a RadMenu ItemClick event on my main form I have this code :
Me.PlaceHolder1.Controls.Add(LoadControl("~/MobileObjects/MobileObject.ascx"))
which correctly adds the UserControl to a place holder on the form....
However some of the UserControls utilise AJAX to do partial updates
using RadManagerProxy, I'm not sure how to get the Ajax working...
Ie. If I click on an ajaxified control within the UserControl which I've loaded, the UserControl simply dissappears...
Please see www.martinhoey.com then top menu "Products" - "Mobile Objects"
to see an example of a control which I need to Add dynamically
and which then uses RadManagerProxy
(Click on the nav buttons to see it working) ....
Regards
Martin Hoey
I have a web site which makes extensive use of Telerik controls
In my current site, I have navigation to various user controls
which already exist declaratively on the page (I just make them visible as required)...
I am changing this so that the User Controls are "loaded as required".
For example in a RadMenu ItemClick event on my main form I have this code :
Me.PlaceHolder1.Controls.Add(LoadControl("~/MobileObjects/MobileObject.ascx"))
which correctly adds the UserControl to a place holder on the form....
However some of the UserControls utilise AJAX to do partial updates
using RadManagerProxy, I'm not sure how to get the Ajax working...
Ie. If I click on an ajaxified control within the UserControl which I've loaded, the UserControl simply dissappears...
Please see www.martinhoey.com then top menu "Products" - "Mobile Objects"
to see an example of a control which I need to Add dynamically
and which then uses RadManagerProxy
(Click on the nav buttons to see it working) ....
Regards
Martin Hoey
6 Answers, 1 is accepted
0
Accepted
Hello Martin,
Can you test if the user control is properly loaded by disabling ajax? If you are not recreating it on page_load it would simply not exist on subsequent postback events. This can easily be verified if you place an asp:Button in your user control - if it is properly loaded the button would trigger postback events, if not it would not trigger any events. A useful article about loading user controls is available here.
Greetings,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Can you test if the user control is properly loaded by disabling ajax? If you are not recreating it on page_load it would simply not exist on subsequent postback events. This can easily be verified if you place an asp:Button in your user control - if it is properly loaded the button would trigger postback events, if not it would not trigger any events. A useful article about loading user controls is available here.
Greetings,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Martin
Top achievements
Rank 1
answered on 12 May 2008, 01:20 PM
Hi Steve
Many thanks, I'm very grateful for your input...
I used the article to load the control on the Page Load
and that resolved my problem fine...
( I even found a use for delegates!)
However, on one of my loadable userControls, I have to include some Javascipt
so that the selection of a RadStrip tab, displays the correct PageView in a RadMultiPage
(This Javascript has to be in the UserControl because I use the find method eg. $find("<%=RadMultiPage2.ClientID %>") )
However this control is not the first "loaded" control
and even though the control is loading correctly, when requested, the page then gives the following Javascript error
'OnClientTabSelected' is undefined
So the page isn't "seeing" the Javascript ??
To see the control working please see www.martinhoey.com which shows the radTabStrip/radMultiPage
working correctly when its loaded immediately...
Any thoughts appreciated...
Regards
Martin Hoey
Below is the Page Load event
==========================================================
If Not (LatestLoadedControlName Is Nothing) Then
LoadUserControl(LatestLoadedControlName)
Else
' The initial content control that is used...
Me.LoadControlPath = "~/Content/"
Me.LoadUserControl("Home.ascx")
' The control that only works if loaded on the page immediately
' Me.LoadControlPath = "~/LegalManagement/"
' Me.LoadUserControl("LegalManagement.ascx")
End If
Below is the Javascript which is in the usercontrol....
==========================================================
// Set the correct tab content
// Only have to do this for top-level tabs
function OnClientTabSelected(sender, args)
{
var tab = args.get_tab();
var tabText = tab.get_text();
//var multiPage = $find("<%=RadMultiPage2.ClientID %>");
var multiPage = $find("<%=RadMultiPage2.ClientID %>");
if (tabText=='Overview')
{
var tabIndex = tab.get_selectedTab().get_index();
multiPage.set_selectedIndex(tabIndex);
}
else if (tabText=='Instruction')
{
var tabIndex = tab.get_selectedTab().get_index();
multiPage.set_selectedIndex(tabIndex+7);
}
else if (tabText=='Management')
{
var tabIndex = tab.get_selectedTab().get_index();
multiPage.set_selectedIndex(tabIndex+12);
}
}
</script>
Many thanks, I'm very grateful for your input...
I used the article to load the control on the Page Load
and that resolved my problem fine...
( I even found a use for delegates!)
However, on one of my loadable userControls, I have to include some Javascipt
so that the selection of a RadStrip tab, displays the correct PageView in a RadMultiPage
(This Javascript has to be in the UserControl because I use the find method eg. $find("<%=RadMultiPage2.ClientID %>") )
However this control is not the first "loaded" control
and even though the control is loading correctly, when requested, the page then gives the following Javascript error
'OnClientTabSelected' is undefined
So the page isn't "seeing" the Javascript ??
To see the control working please see www.martinhoey.com which shows the radTabStrip/radMultiPage
working correctly when its loaded immediately...
Any thoughts appreciated...
Regards
Martin Hoey
Below is the Page Load event
==========================================================
If Not (LatestLoadedControlName Is Nothing) Then
LoadUserControl(LatestLoadedControlName)
Else
' The initial content control that is used...
Me.LoadControlPath = "~/Content/"
Me.LoadUserControl("Home.ascx")
' The control that only works if loaded on the page immediately
' Me.LoadControlPath = "~/LegalManagement/"
' Me.LoadUserControl("LegalManagement.ascx")
End If
Below is the Javascript which is in the usercontrol....
==========================================================
// Set the correct tab content
// Only have to do this for top-level tabs
function OnClientTabSelected(sender, args)
{
var tab = args.get_tab();
var tabText = tab.get_text();
//var multiPage = $find("<%=RadMultiPage2.ClientID %>");
var multiPage = $find("<%=RadMultiPage2.ClientID %>");
if (tabText=='Overview')
{
var tabIndex = tab.get_selectedTab().get_index();
multiPage.set_selectedIndex(tabIndex);
}
else if (tabText=='Instruction')
{
var tabIndex = tab.get_selectedTab().get_index();
multiPage.set_selectedIndex(tabIndex+7);
}
else if (tabText=='Management')
{
var tabIndex = tab.get_selectedTab().get_index();
multiPage.set_selectedIndex(tabIndex+12);
}
}
</script>
0
Accepted
Hello Martin,
You have to wrap your client-side function in RadScriptBlock control when the control/user control containing it is loaded dynamically. More info on RadScriptBlock is available in our help documentation here.
Kind regards,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
You have to wrap your client-side function in RadScriptBlock control when the control/user control containing it is loaded dynamically. More info on RadScriptBlock is available in our help documentation here.
Kind regards,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Martin
Top achievements
Rank 1
answered on 12 May 2008, 03:13 PM
Hi Steve
Many Thanks again, using RadScriptBlock works a dream...
ALMOST!
HOWEVER ....
(WORKS) If I load the control direct from a link on the page
the javascript block arrives on the page OK...
(NOT WORKS) However I also have an instance where I load the control from a link in another usercontrol (Home control)...
To see this problem....
Goto www.martinhoey.com
1) Click on the link in the middle of the page "No obligation trial"
The usercontrol is loaded,,,
There will be a JavaScript Error on the page 'OnClientTabSelected' is not defined
2) Click on the "netObjects" logo at the top-left of the page
This loads the home control again...
3) Click on the menu item "Products" at the top of the page
The usercontrol is loaded,,,
There is now NO Javascript error
The difference in Step 1 (which produces the error)
The link "No obligation trial" is called via a DELEGATE ON THE HOME USER CONTROL
Hope this makes senese
Regards
Martin
Special loading of the HOME UserControl ( Method - LoadUserControl)
===============================================================
IF controlName.StartsWith("Home") Then
' Create control and add it to the Panel
ctrlHome = CType(LoadControl(Me.LoadControlPath & controlName), ASP.Home)
Me.PanelContent.Controls.Add(ctrlHome)
' now create DELEGATE for LoadUserControl method, and send it to the user control
Dim delLoadUserControl As New DelLoadUserControl(AddressOf Me.LoadUserControl)
ctrlHome.LoadUserControl = delLoadUserControl
ELSE
' Normal Control (no delegate required)
' Create control and add it to the Panel
Dim userControl As UserControl = CType(Me.LoadControl(Me.LoadControlPath & controlName), UserControl)
Me.PanelContent.Controls.Add(userControl)
0
Martin
Top achievements
Rank 1
answered on 12 May 2008, 03:21 PM
Hi Steve
The problem with delegates may be difficult to understand
without seeing a working project...
So I'll create a stripped down project which should highlight
the issue...
If you want to see this project, please let me know how to send/attach to you?
Regards
Martin
The problem with delegates may be difficult to understand
without seeing a working project...
So I'll create a stripped down project which should highlight
the issue...
If you want to see this project, please let me know how to send/attach to you?
Regards
Martin
0
Martin
Top achievements
Rank 1
answered on 12 May 2008, 06:38 PM
Hi Steve
MY PROBLEM IS SORTED!
Once again, thanks for all your help, its been invaluable...
Like a good programmer I stripped my code down to a simple project
and realised that when loading the Control
I had to Ajaxify the previous control which linked to it!
In the LoadUserControl methiod on the page...
Me.RadAjaxManager1.AjaxSettings.AddAjaxSetting(ctrlHome, Me.PanelContent, Me.RadAjaxLoadingPanel1)
Thanks again
Regards
Martin
MY PROBLEM IS SORTED!
Once again, thanks for all your help, its been invaluable...
Like a good programmer I stripped my code down to a simple project
and realised that when loading the Control
I had to Ajaxify the previous control which linked to it!
In the LoadUserControl methiod on the page...
Me.RadAjaxManager1.AjaxSettings.AddAjaxSetting(ctrlHome, Me.PanelContent, Me.RadAjaxLoadingPanel1)
Thanks again
Regards
Martin