[CLOSED] [2.0] MVC DirectEvent Error

  1. #1

    [CLOSED] [2.0] MVC DirectEvent Error

    Hello,

    I'm receiving the following error when clicking the "Button 1" button:

    Server Error in '/' Application.
    The control with ID 'ctl02' not found
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    
    Exception Details: System.Web.HttpException: The control with ID 'ctl02' not found
    
    
    Source Error:
    
    
    Line 2965:                        throw new HttpException("The control with ID '{0}' not found".FormatWith(controlID));
    Line 2966:                    }
    Line 2967:                }
    Line 2968:            }
    Line 2969:
    
    
    
    
    Source File: D:\Application\Library\Required Dependencies\Ext.NET\Source\2.0.0.DP1\Ext.Net\Core\ResourceManager\ResourceManager.cs    Line: 2967
    
    
    Stack Trace:
    
    
    [HttpException (0x80004005): The control with ID 'ctl02' not found]
       Ext.Net.ResourceManager.RaisePostBackEvent(String eventArgument) in D:\Application\Library\Required Dependencies\Ext.NET\Source\2.0.0.DP1\Ext.Net\Core\ResourceManager\ResourceManager.cs:2967
       Ext.Net.ResourceManager.Page_AjaxLoadComplete(Object sender, EventArgs e) in D:\Application\Library\Required Dependencies\Ext.NET\Source\2.0.0.DP1\Ext.Net\Core\ResourceManager\ResourceManager.cs:2797
       System.EventHandler.Invoke(Object sender, EventArgs e) +0
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3922
    
    
    
    
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237
    Layout.cshtml:
    <!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>@ViewBag.Title</title>
        </head>
        <body>
            @(Html.X().ResourceManager()
                .IDMode(Ext.Net.IDMode.Static)
            )
    
    
            @RenderBody()
        </body>
    </html>
    Here is the source code for the Login.cshtml:
    @{
        Layout = "~/Views/Shared/Layout.cshtml";
    }
    @(Html.X().Window()
        .BodyPadding(15)
        .Closable(false)
        .Draggable(false)
        .Height(275)
        .Layout(Ext.Net.LayoutType.Fit)
        .Resizable(false)
        .Width(555)
        .Buttons(a =>
        {
            a.Add(Html.X().Button()
                .Scale(Ext.Net.ButtonScale.Medium)
                .Text("Button 1")
                .DirectEvents(events =>
                {
                    events.Click.Buffer = 300;
                    events.Click.FormID = "FormPanel1";
                    events.Click.Method = Ext.Net.HttpMethod.POST;
                    events.Click.Url = Url.Action("Action", "Controller");
                } )
            );
        } )
        .Items(a =>
            a.Add(Html.X().FormPanel()
                .Border(false)
                .ID("FormPanel1")
                .Items(b =>
                {
                    b.Add(Html.X().TextField()
                        .AnchorHorizontal("97%")
                        .FieldLabel("Username")
                        .Name("Username")
                        .Listeners(listeners =>
                        {
                            listeners.AfterRender.Buffer = 300;
                            listeners.AfterRender.Handler = "this.focus();";
                        } )
                    );
                    b.Add(Html.X().TextField()
                        .AnchorHorizontal("97%")
                        .FieldLabel("Password")
                        .InputType(Ext.Net.InputType.Password)
                        .Name("Password")
                    );
                    b.Add(Html.X().Checkbox()
                        .AnchorHorizontal("97%")
                        .BoxLabel("Remember Me")
                        .Checked(true)
                        .Name("RememberMe")
                    );
                } )
            )
        )
    )
    Any suggestions?

    Cheers,
    Timothy
    Last edited by Daniil; Jan 20, 2012 at 1:31 PM. Reason: [CLOSED]
  2. #2
    If DirectEvent is used with Razor then you have to use url which points to controller action, webservice or something else
    The way is used in your sample (inline delegate) will not be supported because there is no way to handle it (there is no 'Control' term under Razor)
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    Can you provide an example of how to wire it for MVC?

    Cheers
  4. #4
    Here you are.

    Example View
    @{
        Layout = "";        
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.NET Razor Example</title>
    </head>
    <body>    
        @Html.X().ResourceManager()
    
        @(Html.X().Button()
            .Text("I am the Buttom with Click DirectEvent")
                
            .DirectEvents(directEvents => {
                directEvents.Click.Url = "/Examples/HelloWorld";
            })
        )
    </body>
    </html>
    Example Controller Action
    public ActionResult HelloWorld()
    {
        string script = X.Msg.Alert("DirectEvent", "Hello World!").ToScript();
        return new AjaxResult(script);
    }

Similar Threads

  1. Replies: 2
    Last Post: Sep 22, 2011, 3:44 AM
  2. Replies: 1
    Last Post: Jun 09, 2011, 8:04 PM
  3. Replies: 7
    Last Post: May 23, 2011, 7:34 PM
  4. TextField DirectEvent Blur Error
    By David Pelaez in forum 1.x Help
    Replies: 5
    Last Post: Dec 21, 2010, 1:32 PM
  5. [CLOSED] Error adding DirectEvent to columnmodel
    By SymSure in forum 1.x Premium Help
    Replies: 6
    Last Post: Apr 07, 2010, 3:11 PM

Tags for this Thread

Posting Permissions