May 27, 2013, 6:59 AM
[OPEN] [#271] How to handle IDMode in PartialViews?
Hi,
We are using partial views and we are setting ID's on the page controls. We are facing the infamous multiple ID issue. I'm submitting an code example on our scenario. We use IDMode.Parent in the resource manager; When we render the partial view the button disappears from the main view and the partial view button is rendered.
Main View: Index.cshtml
Thanks
We are using partial views and we are setting ID's on the page controls. We are facing the infamous multiple ID issue. I'm submitting an code example on our scenario. We use IDMode.Parent in the resource manager; When we render the partial view the button disappears from the main view and the partial view button is rendered.
Main View: Index.cshtml
@{
ViewBag.Title = "Index";
}
<h2>Main View</h2>
@using Ext.Net;
@using Ext.Net.MVC;
@Html.X().ResourceManager().IDMode(IDMode.Parent)
@Html.X().Button().ID("btnPartial").Text("btnPartial")
@Html.X().Panel().ID("tPanel").Layout(LayoutType.Fit).Region(Region.Center).Items().Loader(Html.X().ComponentLoader().Url("Test/PartialView1")
.Mode(LoadMode.Script)
.LoadMask(lm => lm.ShowMask = true)
.Params(para =>
{
para.Add(new { containerId = "tPanel" });
}
))
Partial View: PartialView1.cshtml@using Ext.Net;
@using Ext.Net.MVC;
@(Html.X().Panel().ID("pnlSub").Height(400).Width(400).Layout(LayoutType.Form).Items(Html.X().Button().ID("btnPartial").Text("btnPartial")))
Controllerusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Controllers
{
public class TestController : Controller
{
//
// GET: /Test/
public ActionResult Index()
{
return View();
}
public ActionResult PartialView1(string containerId)
{
Ext.Net.MVC.PartialViewResult pView = new Ext.Net.MVC.PartialViewResult(containerId, Ext.Net.RenderMode.AddTo);
pView.WrapByScriptTag = false;
return pView;
}
}
}
We need more information on how to use the IDMode property correctly. Please advise.Thanks
Last edited by Daniil; Jun 10, 2013 at 3:19 PM.
Reason: [OPEN] [#271]