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

Getting error while accessing items inside panelbar

1 Answer 54 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Aamir Ali Ansari
Top achievements
Rank 2
Aamir Ali Ansari asked on 26 Aug 2010, 11:54 AM
Dear Telerik team

Kindly review the sample code below for an idea of what I need to acheive...

I am getting following error on compilation...The similar script is working fine with page not using Panelbar...

Error
The name 'txtRegister' does not exist in the current context

<script language="javascript" type="text/javascript">
    function btnTemplate_onclick() {
            checkscript();
        
  
 function checkscript(){
  
            var editor = $find("<%=txtRegister.ClientID  %>"); //get a reference to RadEditor client object
  
            mytext = editor.get_html(true);
//Some more steps
}
</script>
  
<telerik:RadPanelBar ID="RadPanelBar1" Runat="server" Width="750px" 
    AllowCollapseAllItems="True" Skin="Office2007">
    <Items
  
<telerik:RadPanelItem runat="server" Text="Deleted Templates" 
            Value="DeletedTemplates">
              <Items>
                <telerik:RadPanelItem runat="server" Value="Test">
                 
                    <ItemTemplate>
  
<telerik:RadEditor ID="txtRegister" Runat="server" EditModes="Html" 
                                        Height="100px" ReadOnly="false" Skin="Sitefinity" ToolbarMode="ShowOnFocus" 
                                        Width="100%" Visible="False">
                                    </telerik:RadEditor>
  
<input id="btnTemplate" type="button" value="Do Something" onclick="return btnTemplate_onclick()" />
  </ItemTemplate>
                 
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelItem>
    </Items>
</telerik:RadPanelBar>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2010, 01:30 PM
Hello,


Since the txtRegister control placed inside the panelbar, you need to get reference to corresponding panelbaritem and then access the editor control.

The following documentation shows more information on this.
Accessing Controls Inside Templates


-Shinu.
Tags
PanelBar
Asked by
Aamir Ali Ansari
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or