PDA

View Full Version : [CLOSED] [2.0] MVC DirectEvent Error



Timothy
Jan 15, 2012, 3:43 PM
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(Obje ct 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

Vladimir
Jan 15, 2012, 6:51 PM
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)

Timothy
Jan 15, 2012, 7:06 PM
Can you provide an example of how to wire it for MVC?

Cheers

Daniil
Jan 16, 2012, 9:59 AM
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);
}