I am using the RadComboBox in an ASP.NET MVC enviroment.
When I let run the RadCombobox within a <form id="form1" runat="server"> all works fine.
But the goal of MVC is to work without a ViewState in order to avoid any overhead, so I try to use the RadComboBox without the ViewState, means use Html.Begin() and Html.EndForm() instead of <form id="form1" runat="server">.
When I do so, the following runtime error occurs:
Runtime error in Microsoft JScript: 'attributes' is Null or not an object
at Line 1900 in Telerik.Web.Ui.Webresource_1.axd
if(_2e["attributes"]){
this.get_attributes()._load(_2e["attributes"]);
}
I assume now, that RadComboBox is only useable when a ViewState is available. If yes, can you tell me which other controls are dependent of the ViewState? And if no, can you tell me what I am doing wrong? Here is my code:
In the MasterPage:
<% using(Html.BeginForm()) { %>
<telerik:RadScriptManager ID="mainRadScriptManager" runat="server" EnableTheming="True" />
......
In the View:
<%
categoryRadComboBox.DataSource = ViewData[
ProductController.Identifiers.DataSources.Categories];
categoryRadComboBox.DataBind();
%>
<telerik:RadComboBox ID="categoryRadComboBox" Runat="server"
AutoPostBack="True" DataTextField="Name"
DataValueField="ProductCategoryID" Height="66px" Width="250px" Skin="Default" MaxHeight="400px">
</telerik:RadComboBox>
And in the Controller:
string categoryValue = RadControlHelper.ExtractComboBoxValue(Request, Identifiers.Controls.CategoriesComboBox);
AdventureWorksDataContext context = new AdventureWorksDataContext();
var categories = from category in context.ProductCategories
orderby category.Name
select new { category.Name, category.ProductCategoryID };
ViewData[
Identifiers.DataSources.Categories] = categories.ToList();
Thanks for your help and best regards.
Hans