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

RadComboBox in MVC only with ViewState?

3 Answers 219 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Housi
Top achievements
Rank 1
Housi asked on 17 Jun 2009, 11:53 AM
Hi all
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

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 17 Jun 2009, 12:13 PM
Hi hans,

Please refer to the controls' documentation under section Integrating RadControls in ASP.NET MVC for details on the matter.

Regards,
Paul
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Housi
Top achievements
Rank 1
answered on 17 Jun 2009, 03:05 PM
Thanks for that quick answer, but I still was referring that documentation which doesn't mention any problems with RadComboBox.

My Combobox works with the <form runat="server"> tag, but fails without that tag. So, does it not work when runat="server" is not present, or should that work without any problems?

Regards
Hans
0
Atanas Korchev
Telerik team
answered on 17 Jun 2009, 03:12 PM
Hi hans,

RadComboBox is an input control and as such requires a form. The same goes with all other input controls - textboxes, checkboxes, radio buttons.

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox
Asked by
Housi
Top achievements
Rank 1
Answers by
Paul
Telerik team
Housi
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or