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

RadComboBox problem on RadTabStrip

1 Answer 122 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Blake
Top achievements
Rank 1
Blake asked on 30 Dec 2008, 10:51 PM
The problem I am having may not be with the TabStrip itself but it only happens when the code is in a Load On Demand TabStrip so I am going to post the question here.

I am not going to post the code for the RadTabStrip/RadMultiPage. I am using the Load On Demand demo exactly and that part is working well. (Except that I am not sure how I should handle loading the initial tab when the page loads).

Each of the tabs has an ascx user control on it. One of them has a RadComboBox that feeds another RadComboBox. The first combo box has a list of regions and when you choose a region it populates the location combo box with locations that pertain to that region. This works fine when I am not using the Load On Demand RadTabStrip but when I switch to the Load On Demand style(which I need to do for performance and validation complications) I get the following error when I try to load the tab with the combo boxes.

A Runtime Error has occured. Do you wish to Debug?
Line: 109201698
Error: 'ClientLoadLocations' is undefined


ClientLoadLocations is the javascript function that is fired on the OnClientSelectedIndexChanging event of the cboRegions combo box. Here is the code for this page omitting some of the unnecessary html:

Can anyone offer a solution so I can stop pulling my hair out?

Thanks for the help.

<script type="text/javascript"
        function ClientLoadLocations(combo, eventargs) 
        { 
            var locationsCombo = $find("<%= cboLocations.ClientID %>"); 
            var item = eventargs.get_item(); 
            locationsCombo.set_text("Loading...");             
             
            if (item.get_index() > 0) 
            { 
                locationsCombo.clearItems(); 
                locationsCombo.requestItems(item.get_value(), false); 
                 
                var comboItem = new Telerik.Web.UI.RadComboBoxItem(); 
                comboItem.set_text("Testing"); 
                locationsCombo.trackChanges(); 
                locationsCombo.get_items().add(comboItem); 
            } 
            else 
            { 
                locationsCombo.set_text(" "); 
                locationsCombo.clearItems(); 
            }         
        } 
                   
        function LocationItemsLoaded(combo, eventargs) 
        { 
            var locationsCombo = $find("<%= cboLocations.ClientID %>"); 
            if (combo.get_items().get_count() > 0) 
              { 
                  combo.set_text(combo.get_items().getItem(0).get_text()); 
                  combo.get_items().getItem(0).highlight();                   
              } 
              combo.showDropDown(); 
        }        
    </script> 
 
     
    <asp:SqlDataSource ID="sdsAsset" runat="server" ProviderName="System.Data.SqlClient"  
    SelectCommandType=  "StoredProcedure" 
    SelectCommand=      "abspAssetManagement_GetIndividualAsset" 
    DataSourceMode=     "DataSet"
    <SelectParameters> 
        <asp:QueryStringParameter Name="AssetID" QueryStringField="AssetID" /> 
    </SelectParameters> 
</asp:SqlDataSource> 
 
 
<table> 
 
    <tr> 
        <td colspan="2"><asp:Label ID="lblDescription" runat="server">Update location infomation about the asset and click the 'Submit' button below.</asp:Label></td
    </tr> 
     
    <tr> 
        <td> 
            <asp:Label ID="lblAssignedTo" runat="server">Region:</asp:Label><br /> 
            <telerik:RadComboBox ID="cboRegions" runat="server" CausesValidation="false" EnableEmbeddedSkins="false" SkinID="CR" Width="250" 
                    OnClientSelectedIndexChanging="ClientLoadLocations"
            </telerik:RadComboBox> 
        </td> 
         
        <td> 
            <asp:Label ID="Label2" runat="server">Floor:</asp:Label><br /> 
            <asp:TextBox ID="txtFloor" runat="server" Width="200" MaxLength="50"></asp:TextBox> 
             
        </td>                         
    </tr> 
                
    <tr> 
        <td> 
            <asp:Label ID="lblAssetName" runat="server">Location:</asp:Label><br /> 
            <telerik:RadComboBox ID="cboLocations" runat="server" CausesValidation="false" EnableEmbeddedSkins="false" SkinID="CR" Width="250" 
                    OnClientItemsRequested="LocationItemsLoaded" 
                    OnItemsRequested="cboLocations_ItemsRequested"
            </telerik:RadComboBox> 
        </td> 
         
        <td> 
            <asp:Label ID="lblAssetDescription" runat="server">Room:</asp:Label><br /> 
            <asp:TextBox ID="txtRoom" runat="server" Width="200" MaxLength="50"></asp:TextBox> 
        </td>                         
    </tr> 
     
     
    <tr> 
        <td> 
            <asp:Button ID="btnSubmit" runat="server" Text="Save" onClick="btnSubmit_Click" />&nbsp; 
            <input type="button" value="Cancel" onclick="history.go(-1)" /> 
            <asp:HiddenField ID="hidAssetID" runat="server" /> 
        </td> 
     
    </tr> 
</table> 


public partial class NET2_AssetManager_UserControls_EDITLocationTAB : System.Web.UI.UserControl 
    #region variables 
 
    private string strSQL = ""
    private string strConnection = ""
    string strCompanyCode; 
 
    string strRegionID; 
    string strLocationID; 
    #endregion 
 
     
    protected void Page_Load(object sender, EventArgs e) 
    { 
        //Hardcode 
        strCompanyCode = "0"
 
        //strConnection = ConfigurationManager.ConnectionStrings["conn_crdemo"].ToString(); 
        strConnection = CRConfiguration.Conn; 
        sdsAsset.ConnectionString = strConnection; 
 
        if (!IsPostBack) 
        { 
 
            DataView dvSql = (DataView)sdsAsset.Select(DataSourceSelectArguments.Empty); 
            foreach (DataRowView drvSql in dvSql) 
            { 
                hidAssetID.Value = drvSql["AssetID"].ToString(); 
 
                //strRegionID will be used to select the appropriate item in the Region combo box 
                strRegionID = drvSql["RegionID"].ToString(); 
                //strLocationID will be used to select the appropriate item in the Location combo box 
                strLocationID = drvSql["LocationID"].ToString(); 
 
 
                txtFloor.Text = drvSql["Floor"].ToString(); 
                txtRoom.Text = drvSql["Room"].ToString(); 
            } 
 
            LoadRegions(); 
            LoadLocations(strRegionID); 
        } 
 
        cboRegions.Focus(); 
    } 
 
 
    protected void btnSubmit_Click(object sender, EventArgs e) 
    {       
    } 
 
 
    protected void cboLocations_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) 
    {         
        LoadLocations(e.Text);         
    } 
 
 
    private void LoadRegions() 
    {         
        DataTable dtRegions = new DataTable(); 
        strSQL = "abspCommon_RegionListByCompany '" + strCompanyCode + "'"
        dtRegions = CRAccess.GetDataTable(strSQL); 
 
        cboRegions.DataTextField = "Region"
        cboRegions.DataValueField = "ID"
        cboRegions.DataSource = dtRegions; 
        cboRegions.DataBind(); 
        cboRegions.Items.Insert(0, new RadComboBoxItem("Select A Region...")); 
 
        if (!IsPostBack) 
        { 
            if (strRegionID != "0"
            { 
                cboRegions.Items.FindItemByValue(strRegionID).Selected = true
            } 
        }         
    } 
 
    private void LoadLocations(string strRegionID) 
    {         
        DataTable dtLocations = new DataTable(); 
        strSQL = "abspCommon_LocationListByCompanyAndRegion '" + strCompanyCode + "','" + strRegionID + "'"
        dtLocations = CRAccess.GetDataTable(strSQL); 
 
        cboLocations.DataTextField = "Name"
        cboLocations.DataValueField = "ID"
        cboLocations.DataSource = dtLocations; 
        cboLocations.DataBind(); 
        cboLocations.Items.Insert(0, new RadComboBoxItem("Select A Location...")); 
 
        if (!IsPostBack) 
        { 
            if (strLocationID != "0" && strLocationID != ""
            { 
                cboLocations.Items.FindItemByValue(strLocationID).Selected = true
            } 
        }             
    } 



1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 02 Jan 2009, 11:06 AM
Hello Blake,

Please try placing all script code inside <telerik:RadScriptBlock> controls. This is required so your javascript code is evaluated after ajax requests:

<telerik:RadScriptBlock runat="server">
   <script type="text/javascript">
          //Your JavaScript here
   </script>
</telerik:RadScriptBlock>

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TabStrip
Asked by
Blake
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or