PDA

View Full Version : Migrating from EXT.Net 4.7 to 7.2 Classic (for Core) - Syntax question



craigthames
Dec 03, 2020, 4:04 PM
Hi, my team is migrating from EXT.Net 4.7 (.Net Framework) into EXT.NET 7.2 Classic for Core. We have been using the MVC/Razor syntax for views for years and hoped we would find the same syntax available here. Is that something that still exists? Knowing that 7.2 is still very new, I haven't found any similar questions.

Thanks so much!

Example of what I'm looking for


@{
ViewBag.Title = "Default Button - Ext.NET MVC Examples";
Layout = "~/Views/Shared/_BaseLayout.cshtml";
var X = Html.X();
}

@section example
{
@(X.Container()
.Layout(LayoutType.VBox)
.Height(650)
.Items(
X.FormPanel()
.Title("Last Button by default")
.BodyPadding(5)
.Width(350)
.Items(
X.TextField()
.FieldLabel("Item 1"),
X.TextField()
.FieldLabel("Item 2")
)
.Buttons(
X.Button().
Text("Button 1"),
X.Button()
.Text("Button 2")
.OnClientClick("Ext.Msg.alert('ENTER', 'ENTER is intercepted by Button2');")
),

X.FormPanel()
.Title("Button by Index")
.DefaultButton("1")
.BodyPadding(5)
.Width(350)
.Items(
X.TextField()
.FieldLabel("Item 1"),
X.TextField()
.FieldLabel("Item 2")
)
.Buttons(
X.Button().
Text("Button 1"),
X.Button()
.Text("Button 2")
.OnClientClick("Ext.Msg.alert('ENTER', 'ENTER is intercepted by Button2');"),
X.Button().
Text("Button 3"),
X.Button().
Text("Button 4")
),

X.FormPanel()
.Title("Button by ID")
.DefaultButton("Button2")
.BodyPadding(5)
.Width(350)
.Items(
X.TextField()
.FieldLabel("Item 1"),
X.TextField()
.FieldLabel("Item 2")
)
.Buttons(
X.Button().
Text("Button 1"),
X.Button()
.Text("Button 2")
.ID("Button2")
.OnClientClick("Ext.Msg.alert('ENTER', 'ENTER is intercepted by Button2');"),
X.Button().
Text("Button 3"),
X.Button().
Text("Button 4")
),

X.FormPanel()
.Title("Button by Selector")
.DefaultButton("button[text=Button 2]")
.BodyPadding(5)
.Width(350)
.Items(
X.TextField()
.FieldLabel("Item 1"),
X.TextField()
.FieldLabel("Item 2")
)
.Buttons(
X.Button().
Text("Button 1"),
X.Button()
.Text("Button 2")
.OnClientClick("Ext.Msg.alert('ENTER', 'ENTER is intercepted by Button2');"),
X.Button().
Text("Button 3"),
X.Button().
Text("Button 4")
)
)
)
}

geoffrey.mcgill
Dec 03, 2020, 8:14 PM
Hi. I was able to run the sample you provided [basically] unchanged in Ext.NET Classic v7.2.0 on .NET 5.0.

Here's the diff, https://www.diffchecker.com/J1i1wz8k

The only diff I ran into was .ID("Button2") needed to be revised to .Id("Button2"). I'll create an issue for that and we will discuss adding a .ID() HtmlHelper to help with backwards compatibility. Although, I also don't see performing a search-and-replace for .ID( to .Id( that big of deal either.

Hope this helps.

craigthames
Dec 07, 2020, 11:42 AM
That wasn't what I was having trouble with. It was actually the code that was needed in _ViewImports.cshtml that I was missing. If anyone else runs into this question, this link should help:

https://docs.ext.net/guides/getting_started/

geoffrey.mcgill
Dec 07, 2020, 10:53 PM
Thanks for the update.

Just as a quick follow-up for anyone reading this thread in the future, installing the Ext.NET Templates (https://docs.ext.net/guides/getting_started/#install-dotnet-cli-templates) and running the dotnet new extnet-mvc command will quickly setup Ext.NET Classic into a new MVC project.

Same thing if you install the Visual Studio Extensions (https://docs.ext.net/guides/getting_started/#install-vsix-visual-studio-extension). and then File > New > Project... and select the Ext.NET MVC Web App project type.

Hope this helps.