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

How to add a tab with content (server-side)?

6 Answers 202 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
dave
Top achievements
Rank 1
dave asked on 06 Jul 2010, 03:36 PM

I'm sure I'm missing something simple here! I want to load content from my database into several tabs. I have the standard RadTabStrip and RadMultiPage element set up in the aspx code.

In my backend VB code I want to add several tabs. I have this so far:

Dim tab As RadTab = New RadTab  
Me.TabStrip.Tabs.Add(tab)  
tab.Text = "Tab #3"  
 
' this bit is not doing anything at present  
Dim pageView As RadPageView = New RadPageView  
Me.TabPages.PageViews.Add(pageView)  
 

The tab gets added to the tab strip, but when I click it there is no content area. I've looked through all the examples and haven't seen anything that actually adds the tab content, only the tabs. Can anyone help?

6 Answers, 1 is accepted

Sort by
0
dave
Top achievements
Rank 1
answered on 07 Jul 2010, 10:26 AM

I figured it out eventually. Firstly I had mismatching IDs on the RadMultiPage element and the MultiPageID attribute of RadTabStrip.

Next between the two pageView lines of code at the bottom, you need to add this to add content to the tab:

pageView.Controls.Add(element) 

0
dave
Top achievements
Rank 1
answered on 19 Jul 2010, 09:52 PM

Now I have another problem... the above work fine when displaying the editors (I have a RadEditor in each tab), but when trying to save the data I can't get hold of the editor controls. I'm using the RadAjaxManager to call this function when I click the save button in any of the editors:

01.Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
02.    If e.Argument = "Save" Then
03.        For Each pageView As RadPageView In Me.TabPages.PageViews
04.            'Dim editor As RadEditor = pageView.Controls.Item(0)
05.            RadAjaxManager1.Alert(pageView.ID & "\n" & pageView.Controls.Count)
06.        Next
07. 
08.        RadAjaxManager1.Alert("Client notes saved.")
09.    End If
10.End Sub

I get an error on the commented line because the pageView doesn't have any controls in it - but I added them in and they're displaying okay! How can I get the content from the RadEditors on my page? Or is it possible to at least get the one that's being saved?

0
Yana
Telerik team
answered on 20 Jul 2010, 10:03 AM
Hello Dave,

When you add the editor dynamically to the pageview it is not persistent after a postback and should be added again - actually this is true for all dynamically added controls.

All the best,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
dave
Top achievements
Rank 1
answered on 20 Jul 2010, 10:10 AM
Thanks for the response. Will I still be able to get the modified content from the editor though? Do I need to add the editor, but not set the content?
0
dave
Top achievements
Rank 1
answered on 20 Jul 2010, 01:51 PM

I gave it a try and no luck. Is there a way to pass the content and ID into the AjaxRequest function? I have this javascript that handles the Save command:

1.function ajaxRequest(operation) {
2.    var ajaxManager = <%= RadAjaxManager1.ClientID %>;
3.    ajaxManager.ajaxRequest(operation);
4.}
5.  
6.RadEditorCommandList["Save"] = function(commandName, editor, oTool) {
7.    ajaxRequest("Save");
8.}

I'm guessing I would use the "editor" parameter there. I managed to find an object member with the HTML - editor._contentArea.innerHTML - but I can't find the ID.

The other problem is how to pass this into the server-side funciton, because I can only seem to pass one value, "operation". On the sever-side, e.Argument just contains "Save" and nothing else.

0
Yana
Telerik team
answered on 23 Jul 2010, 09:24 AM
Hello dave,

You can read how to pass more than one argument here.

Regarding the editor id and text, you can use the following methods:

editor.get_id();
editor.get_text();

More information about the client-side API of RadEditor can be found here.

Best wishes,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TabStrip
Asked by
dave
Top achievements
Rank 1
Answers by
dave
Top achievements
Rank 1
Yana
Telerik team
Share this question
or