[CLOSED] [1.0] ComboBox Problem

  1. #1

    [CLOSED] [1.0] ComboBox Problem

    Hello,

    The following demonstrates an issue with the ComboBox in MVC (2):

    ExampleController.cs:
        public class Example
        {
            public string Selected { get; set; }
        }
    
        public class ExampleController : System.Web.Mvc.Controller
        {
            public ActionResult Index()
            {
                return View();
            }
    
            public ActionResult Child()
            {
                var example = new Example
                {
                    Selected = "Timothy"
                };
    
                var result = PartialExtView(example);
    
                result.ContainerId = "Panel1";
                result.RenderMode = Ext.Net.RenderMode.AddTo;
                result.WrapByScriptTag = false;
    
                return result;
            }
    
            public ActionResult Child2()
            {
                return PartialExtView();
            }
        }
    Index.aspx:
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" IDMode="Explicit" ScriptMode="Debug" Theme="Gray" />
        <ext:Panel ID="Panel1" runat="server" Height="100">
            <Listeners>
                <AfterRender Handler="Ext.Ajax.request( {
                        disableCaching: true,
                        scripts: true,
                        success: function(response) {
                            eval(response.responseText)
                        },
                        url: '/Example/Child'
                    } );" />
            </Listeners>
        </ext:Panel>
    </body>
    </html>
    Child.ascx:
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Web.Controllers.Example>" %>
    <%= Html.RenderExtPartial("Child2", Model) %>
    Child2.ascx:
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Web.Controllers.Example>" %>
    <ext:ComboBox ID="ComboBox1" runat="server">
        <Items>
            <ext:ListItem Text="Timothy" Value="Timothy" />
        </Items>
        <SelectedItem AutoDataBind="true" Value='<%# Model.Selected %>' />
    </ext:ComboBox>
    Should select Timothy from the ComboBox1 but is not. I'm also seeing this problem with the TimeField but I suspect it's related because the TimeField inherits from the ComboBox.

    Cheers,
    Timothy
  2. #2

    RE: [CLOSED] [1.0] ComboBox Problem

    Hi,

    Fixed. Your example works correctly now. Please update Ext.Net.MVC
  3. #3

    RE: [CLOSED] [1.0] ComboBox Problem

    Works for ComboBox but not working for TimeField check example:

    ExampleController.cs:
    	public class Example
    	{
    		public TimeSpan Time { get; set; }
    	}
    
    
    	public class ExampleController : System.Web.Mvc.Controller
    	{
    		public ActionResult Index()
    		{
    			return View();
    		}
    
    
    		public ActionResult Child()
    		{
    			var example = new Example
    			{
    				Time = DateTime.Now.TimeOfDay
    			};
    
    
    			var result = PartialExtView(example);
    
    
    			result.ContainerId = "Panel1";
    			result.RenderMode = Ext.Net.RenderMode.AddTo;
    			result.WrapByScriptTag = false;
    
    
    			return result;
    		}
    
    
    		public ActionResult Child2()
    		{
    			return PartialExtView();
    		}
    	}

    Index.aspx:
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    	<title>Example</title>
    </head>
    <body>
    	<ext:ResourceManager runat="server" IDMode="Explicit" ScriptMode="Debug" Theme="Gray" />
    	<ext:Panel ID="Panel1" runat="server" Height="100">
    		<Listeners>
    			<AfterRender Handler="Ext.Ajax.request( {
    					disableCaching: true,
    					scripts: true,
    					success: function(response) {
    						eval(response.responseText)
    					},
    					url: '/Example/Child'
    				} );" />
    		</Listeners>
    	</ext:Panel>
    </body>
    </html>

    Child.ascx:
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Web.Controllers.Example>" %>
    <%= Html.RenderExtPartial("Child2", Model) %>

    Child2.ascx:
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Web.Controllers.Example>" %>
    <ext:TimeField runat="server" SelectedTime='<%# Model.Time %>' />
  4. #4

    RE: [CLOSED] [1.0] ComboBox Problem

    Hi,

    I think you have to set AutoDataBind="true" for the TimeField
  5. #5

    RE: [CLOSED] [1.0] ComboBox Problem

    Thanks vladimir, sorry I posted an out of date example, I have the AutoDataBind="true" enabled on my TimeField and I'm still having the same result :(

    Cheers
  6. #6

    RE: [CLOSED] [1.0] ComboBox Problem

    Hi,

    Fixed. Please update Ext.Net
  7. #7

    RE: [CLOSED] [1.0] ComboBox Problem

    Solved, thanks again vladimir :)

Similar Threads

  1. [CLOSED] ComboBox DirectEvent problem
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Jun 25, 2012, 8:02 PM
  2. [CLOSED] Problem with ComboBox
    By FVNoel in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 07, 2012, 1:58 PM
  3. [CLOSED] combobox problem
    By majestic in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Oct 23, 2009, 10:19 AM
  4. Replies: 5
    Last Post: Jun 10, 2009, 5:13 AM
  5. [CLOSED] Combobox problem
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 28, 2009, 9:13 AM

Posting Permissions