PDA

View Full Version : [CLOSED] PartialViewRenderer Razor



Timothy
Jun 03, 2012, 3:50 PM
Hello,

Just curious if you have any timeline for the PartialViewRenderer to support Razor? I've hit numerous parts in my application testing that would make this extremely useful :)

Any suggestions how to get around not having the support? Would you suggest XHR calls for the time being?

Cheers,
Timothy

Vladimir
Jun 03, 2012, 4:40 PM
Hi,

I will try to implement it on this week

Vladimir
Jun 03, 2012, 4:42 PM
By the way, i found that Html.Partial works correctly in my test case with Ext.Net widgets (Razor)


@Html.Partial("PartialRazorView")


Can you confirm it? Or there are aby issues?

Timothy
Jun 03, 2012, 4:54 PM
Hello vladsch,

Thanks for looking into it. Only problem with @Html.Partial() is that it does not support single control, especially if you are trying to stack the controls. The content of my partial view is a single control with children.

Hope that makes sense?

I'm going to use XHR calls for the time being.

Cheers,
Timothy

Vladimir
Jun 03, 2012, 5:13 PM
Can you provide more details about "@Html.Partial() is that it does not support single control"? What single control do you mean?

Timothy
Jun 03, 2012, 5:23 PM
Can you provide more details about "@Html.Partial() is that it does not support single control"? What single control do you mean?

Ext.Net/MVC/PartialViewResult.cs line 77

vladsch, I think .ItemsFromPage() and .ContentFromPage() might actually be the MVC Razor equivalent of PartialViewRenderer in ASP.NET Forms. Perhaps having PartialViewRenderer support Razor would be a redundant task since you already have ItemFromPage/ContentFromPage?

Cheers

Vladimir
Jun 03, 2012, 5:30 PM
SingleControl is supported by WebForm engine only because Razor doesn't know about control term and we have no any controls hierarchy under Razor



Perhaps having PartialViewRenderer support Razor would be a redundant task single you already have ItemFromPage/ContentFromPage?

May be but ItemFromPage/ContentFromPage doesn't support passing of another model and view data (like Html.Partial)

Timothy
Jun 03, 2012, 5:38 PM
May be but ItemFromPage/ContentFromPage doesn't support passing of another model and view data (like Html.Partial)

Thanks, I'll leave the decision up to you guys on how to best handle it. ItemsFromPage/ContentFromPage are going to satisfy my requirements as I do not have another model / view data to pass to my pages.

Also, thanks for the clarification on the SingleControl in the MVC Razor structure.

Cheers,
Timothy

Vladimir
Jun 03, 2012, 6:11 PM
I attached zip file with MVC sandbox project, it contains several useful examples of ItemsFromSection, ItemsFromPage methods (just rename txt to zip after downloading)

Timothy
Jun 07, 2012, 12:23 PM
Thanks vladsch, you can close this item. I appreciate the demo zip :)

Cheers

UnifyEducation
Jul 24, 2012, 11:55 PM
I attached zip file with MVC sandbox project, it contains several useful examples of ItemsFromSection, ItemsFromPage methods (just rename txt to zip after downloading)

Thanks Vladimir for your great example.
I tried with MVC4 but nothing happen when I click render view. Here is the code:
/Home/Index.cshtml:

@using Ext.Net
@using Ext.Net.MVC
@{
Layout = "";
}
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
</head>
<body>
@Html.X().ResourceManager()

@(Html.X().Panel()
.ID("Panel1")
.Padding(5)
.Layout(LayoutType.Fit)
.BodyPadding(5)
.Title("Panel1")
.Width(400)
.Height(200)
.Icon(Icon.Add)
.Buttons(buttons => {
buttons.Add(Html.X().Button().Text("Render view").DirectEvents(e => {
e.Click.Url = "/Home/PartialRazorView/";
e.Click.EventMask.ShowMask = true;
e.Click.ExtraParams.Add(new Parameter("containerId", "App.Panel1"));
}));
})
)

@(Html.X().Panel()
.ID("Panel2")
.Padding(5)
.BodyPadding(5)
.Title("Panel2")
.Width(400)
.Height(200)
.Icon(Icon.Add)
.Buttons(buttons => {
buttons.Add(Html.X().Button().Text("Render view").DirectEvents(e => {
e.Click.Url = "/Home/PartialRazorView2/";
e.Click.EventMask.ShowMask = true;
e.Click.ExtraParams.Add(new Parameter("containerId", "App.Panel2.body.id", ParameterMode.Raw));
}));
})
)
</body>
</html>

/Home/PartialRazorView.cshtml:

@using Ext.Net.MVC

@(
Html.X().Panel()
.Title("Panel from partial view")
.Content(@<text>
<h3>Simple content</h3>
@Html.X().Button().Text("Button")
</text>)
)

/Controllers/HomeComtroller.cs

public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}

public Ext.Net.MVC.PartialViewResult PartialRazorView(string containerId)
{
return new Ext.Net.MVC.PartialViewResult(containerId, RenderMode.AddTo);
}

public Ext.Net.MVC.PartialViewResult PartialRazorView2(string containerId)
{
return new Ext.Net.MVC.PartialViewResult(containerId, RenderMode.RenderTo);
}
}

Do you have any idea to resolve this problem in MVC4

Daniil
Jul 25, 2012, 12:54 AM
Hi @UnifyEducation,

Please start a new forum thread.

If you feel the threads are related, please cross link between the two.