[mapguide-users] Re: Edit WebLayout Problem

SriRam007 binod_tripathy at yahoo.co.in
Wed Apr 14 06:27:54 EDT 2010


I m trying to make tool bar invisible
this is the code how i m doing But not working

protected void btn_Click(object sender, EventArgs e) 
{
Utility.InitializeWebTier(Request);
        MgUserInformation userInfo = new
MgUserInformation(Session["ID"].ToString());
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);
        MgResourceService resourceService =
siteConnection.CreateService(MgServiceType.ResourceService) as
MgResourceService;
        MgMap map = new MgMap();
        map.Open(resourceService, "Sheboygan");

        MgResourceIdentifier WebLayoutId = new
MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganAsp.WebLayout");
        MgByteReader byteReader =
resourceService.GetResourceContent(WebLayoutId);

        string xmlLayoutDef = byteReader.ToString();
        string MapDefinitionStr = ReplaceTextNodeValue(xmlLayoutDef,
"false");//Here i m finding the tool bar node and then visible node and
replacing the value true to false

        XmlDocument newLayoutXML = new XmlDocument();
        newLayoutXML.LoadXml(MapDefinitionStr.ToString());
        
        MgResourceIdentifier MapResId = new MgResourceIdentifier("Session:"
+ Session["ID"].ToString() + "//" + "SheboyganAsp.WebLayout");
        resourceService.SetResource(MapResId, new
MgByteReader(MapDefinitionStr, "text/xml"), null);//WebLayoutId
        resourceService.UpdateRepository(MapResId, new
MgByteReader(MapDefinitionStr, "text/xml"), null);
        map.Save(resourceService);
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
"RefreshMap", "parent.parent.mapFrame.Refresh();", true);
}

private static string ReplaceTextNodeValue(string byteReaderStr, string
ReplaceValue) 
    { 
        XmlDocument doc = new XmlDocument(); 
        doc.LoadXml(byteReaderStr.ToString()); 
        XmlNodeList ToolBarnodeList = doc.GetElementsByTagName("ToolBar"); 
        foreach (XmlElement node in ToolBarnodeList) 
        { 
            XmlNodeList VisibleNodeList =
node.GetElementsByTagName("Visible"); 
            if (VisibleNodeList.Count > 0) 
            { 
                VisibleNodeList.Item(0).FirstChild.Value =
ReplaceValue.ToString(); 
            } 
        } 
        string MapDefinitionStr = doc.OuterXml.ToString(); 
        return MapDefinitionStr; 
        
    } 


Please anyone help me where i did wrong

thanks
-- 
View this message in context: http://n2.nabble.com/Edit-WebLayout-Problem-tp4869470p4900872.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list