hello,
I try actually to use the WebDropDown Control and want to raise the event: OnSelectionChanged but i am still getting "__doPostBack is not defined" .....
<igl:WebDropDown ID="WebDorpdown" EnablePaging="false" Width="200px" DropDownAnimationType="EaseOut" PageSize="10" OnSelectionChanged="WebDorpdown_SelectionChanged" TextField="value" DisplayMode="DropDownList" ValueField="key" runat="server"> <ClientEvents /> <AutoPostBackFlags SelectionChanged="On" /> </igl:WebDropDown> <cc1:IGMvcScriptManager ID="sm" runat="server" />
Code Behind:
WebDorpdown.SelectionChanged +=WebDorpdown_SelectionChanged; in page_load
protected void WebDorpdown_SelectionChanged(object sender, DropDownSelectionChangedEventArgs e) { ..... }
any idea or solution?? thanks
Hi,
Is this in the context of MVC ? Which is this script manager?
Thanks,
Angel
yes this is in the context of MVC and use <%@ Register Assembly="Infragistics.Web.Mvc" Namespace="Infragistics.Web.Mvc" TagPrefix="cc1" %>
Thanks
This approach will not work because the MVC framework does not support post backs. You will want to initiate a post to a controller action and read the values from the form collection or create a custom model binder to find the new value.
Our reference application has this functionality implemented, you may want to look at the following links:
http://netadvantagemvc.codeplex.com/SourceControl/changeset/view/20332#407758
http://netadvantagemvc.codeplex.com/SourceControl/changeset/view/20332#407767
Notice how the RichIssueBinder is implemented.
HTH,
Craig
Thanks Craig for your Answer,
But it is not what i am expected. to set Dropdownlist and send it via submit Button in asp.net mvc work fine. But what i want is to get the event of Dropdown on Server-Side and not on Client-Side using JavaScript.
I want to realize "Chart in a WebAsyncRefreshPanel" using a DropdownList - SelectionOnChanged.
Hi
Thanks for your reply
Now I have one issue (MVC with Infragistics Controls)I have a web dropdown and on change of dropdown I want to bind webdatagrid, I am doing like this and my code is as:-
Controller –
For dropdown bind
public ActionResult ActiveProjects()
{
var vm = new ProjectDropDownVM();
string sOrgId = "abe";
vm.lstProject = _projectService.GetProjectNames(sOrgId);
return View(vm);
}
For grid bind
public JsonResult GetData(int Id)
vm.lstProject = _projectService.GetProjectNames(Id);
return this.Json(vm);
View- Code to bond drop down
<%
this.wcProject.DataSource = this.Model.lstProject;
this.wcProject.DataBind();
%>
Now on drop down change I want to bind webdatagrid, I am doing this by using client event <ClientEvents SelectionChanged="wcProject_SelectionChanged" />
<script language="javascript" type="text/javascript">
function wcProject_SelectionChanged(sender, eventArgs) {
// get the text/Value of the selected item
var selectedProjecty = sender.get_selectedItem().get_text();
var selectedProjectValue = sender.get_selectedItem().get_value();
alert("1");
var grid;
var dataSource;
var newData;
var numRows;
var newData = $.getJSON("/Projects/GetData", selectedProjectValue, function (data) {
alert("2");
grid = $find('<%=WebDataGrid1.ClientID%>');
dataSource = grid._get_dataSource();
newData = JSON.parse(data.d);
var item;
for (var i = 0; i < newData.length; i++) {
item = newData[i];
$(grid.tableTemplate).render(item).appendTo(grid._elements.dataTbl.lastChild);
dataSource.push(newData[i]);
grid._set_dataSource(dataSource);
grid._applyClientBinding();
numRows = grid.get_rows().get_length();
});
</script>
I am unable to fetch data or bind dataGrid plz suggest how can I resolve this Or any other way is there to resolve this.
Mourbare:
The issue you are hitting here is that the approach you are trying to take makes use of postbacks.The postback/code-behind approach doesn't play well with MVC applications.
It sounds like you want to is to initiate an Ajax call back as a result of a change in the DropDownList.Then once the Ajax call contacts the server you can do some processing and allow the call back to provide data to any other component on the page.