xml control visibility

D

-D-

How can I turn the visibility of the xml control on or off?

<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="TopNavBar.ascx.cs" Inherits="compass.user_controls.TopNavBar"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<table cellSpacing="0" cellPadding="0" border="0">
<colgroup span="1" align="left" width="50%">
</colgroup>
<colgroup span="1" align="right" width="50%">
</colgroup>
<tr>
<td>
<asp:Xml Runat="server" DocumentSource="../sitemap.xml"
TransformSource="../topnavigationbar.xslt"
id="Xml1"></asp:Xml>
</td>
<td>
<form style="MARGIN: 0px" name="frmSearch" action="search.asp"
method="post">
Search <input type="text" size="25" name="txtQuery"> <A
href="javascript:document.frmSearch.submit()">
<IMG src="images/go.gif" align="absMiddle" border="0"></A>
</form>
</td>
</tr>
</table>

This is the code behind:

namespace compass.user_controls
{
using System;
using System.Collections;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using compass.ClassFiles;

/// <summary>
/// Summary description for TopNavBar.
/// </summary>
public class TopNavBar : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Xml Xml1;
protected System.Web.UI.WebControls.Repeater Repeater1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}



Also, the xslt file generates an unordered list. Is there a way to set the
visibility for one of the list items on or off in the code behind?

For example, if five list items are displaying and I want to hide the
visibility of one of the items, is there a way to do this?
 
M

Michael Nemtsev

Hello -D-,

Xml control has Visible property that can be set in True/False

-> How can I turn the visibility of the xml control on or off?
->
-> <%@ Control Language="c#" AutoEventWireup="false"
-> Codebehind="TopNavBar.ascx.cs"
-> Inherits="compass.user_controls.TopNavBar"
-> TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
-> <table cellSpacing="0" cellPadding="0" border="0">
-> <colgroup span="1" align="left" width="50%">
-> </colgroup>
-> <colgroup span="1" align="right" width="50%">
-> </colgroup>
-> <tr>
-> <td>
-> <asp:Xml Runat="server" DocumentSource="../sitemap.xml"
-> TransformSource="../topnavigationbar.xslt"
-> id="Xml1"></asp:Xml>
-> </td>
-> <td>
-> <form style="MARGIN: 0px" name="frmSearch" action="search.asp"
-> method="post">
-> Search <input type="text" size="25" name="txtQuery"> <A
-> href="javascript:document.frmSearch.submit()">
-> <IMG src="images/go.gif" align="absMiddle" border="0"></A>
-> </form>
-> </td>
-> </tr>
-> </table>
-> This is the code behind:
->
-> namespace compass.user_controls
-> {
-> using System;
-> using System.Collections;
-> using System.Data;
-> using System.Drawing;
-> using System.Web;
-> using System.Web.UI.WebControls;
-> using System.Web.UI.HtmlControls;
-> using System.Xml;
-> using compass.ClassFiles;
-> /// <summary>
-> /// Summary description for TopNavBar.
-> /// </summary>
-> public class TopNavBar : System.Web.UI.UserControl
-> {
-> protected System.Web.UI.WebControls.Xml Xml1;
-> protected System.Web.UI.WebControls.Repeater Repeater1;
-> private void Page_Load(object sender, System.EventArgs e)
-> {
-> // Put user code to initialize the page here
-> }
->
-> #region Web Form Designer generated code
-> override protected void OnInit(EventArgs e)
-> {
-> //
-> // CODEGEN: This call is required by the ASP.NET Web Form
-> Designer.
-> //
-> InitializeComponent();
-> base.OnInit(e);
-> }
-> /// <summary>
-> /// Required method for Designer support - do not modify
-> /// the contents of this method with the code editor.
-> /// </summary>
-> private void InitializeComponent()
-> {
-> this.Load += new System.EventHandler(this.Page_Load);
-> }
-> #endregion
-> }
-> }
-> Also, the xslt file generates an unordered list. Is there a way to
-> set the visibility for one of the list items on or off in the code
-> behind?
->
-> For example, if five list items are displaying and I want to hide the
-> visibility of one of the items, is there a way to do this?
->
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
D

-D-

Michael,

Thanks for the info. I'm using the xml control within a user control that I
have placed in all my pages. On some of the pages, I want to turn the
visibility of the xml control to false.

How would I specify the xml control visibility in my aspx pages, so that I
can control the visibility independently for each one of my pages?

Thanks,
-D-
 
M

Michael Nemtsev

Hello -D-,

<asp:Xml Runat="server" Visible=false ..>
BTW, if you open IE with you page you can call context menu and press ViewSource,
found with html tag (probably <div>) is responsible for you Xml control and
then use JS document.getcontrolbyid().style.display to contol you visibility
dynamically


-> Michael,
->
-> Thanks for the info. I'm using the xml control within a user control
-> that I have placed in all my pages. On some of the pages, I want to
-> turn the visibility of the xml control to false.
->
-> How would I specify the xml control visibility in my aspx pages, so
-> that I can control the visibility independently for each one of my
-> pages?
->
-> Thanks,
-> -D-
-> ->-> not
->---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
D

-D-

Thanks Michael,

I was looking for an id in the source to contol the visibility dynamically.
I checked the view source for the list items:

<?xml version="1.0" encoding="utf-8"?><ul><li><a
href="index.aspx">Home</a></li><li><a href="/about_us/index.aspx">About
Us</a></li><li><a href="contact.aspx">Contact Us</a></li><li><a
href="http://support.compasslearning.com">Customer Support</a></li><li><a
href="sitemap.aspx">Site Map</a></li></ul>

Should an id be generated automatically for the unordered list? Or, do I
need to specify one in the control?
 
M

Michael Nemtsev

Hello -D-,

Have no wrapper for your xml control there.
In that case create <div> with ID around you XML control like

<div id="xmlDiv">
<asp:Xml Runat="server" DocumentSource="../sitemap.xml" TransformSource="../topnavigationbar.xslt"
id="Xml1"></asp:Xml>
</div>

and look for xmlDiv in you source, that will wrap you xml


-> Thanks Michael,
->
-> I was looking for an id in the source to contol the visibility
-> dynamically. I checked the view source for the list items:
->
-> <?xml version="1.0" encoding="utf-8"?><ul><li><a
-> href="index.aspx">Home</a></li><li><a
-> href="/about_us/index.aspx">About Us</a></li><li><a
-> href="contact.aspx">Contact Us</a></li><li><a
-> href="http://support.compasslearning.com">Customer
-> Support</a></li><li><a href="sitemap.aspx">Site Map</a></li></ul>
->
-> Should an id be generated automatically for the unordered list? Or,
-> do I need to specify one in the control?
->
-> ->-> ViewSource,
->-> and
->-> visibility
->
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
D

-D-

Hello Michael,

Thanks for the help. Okay, that works. I can turn the visibility of the
entire control on or off independently for specific pages. Is there a way
to control the visibility of a specific list item?

For example the xml control displays an unordered list with 5 list items.
So, on certain pages, I want to only show 4 of the 5 list items. Based on
your example, I'd need a different id for every <li> tag. How can I set an
id for each <li> tag? Is there a way to do that? Can I modify my xml/xslt
pages to add the id?

I really appreciate your help.

-D-
 
M

Michael Nemtsev

Hello -D-,

Is that you form control? For that case you can set id for it, or try to
change your xslt

PS: could you post you project sample on some public places where it could
be downloaded to help u?

-> Hello Michael,
->
-> Thanks for the help. Okay, that works. I can turn the visibility of
-> the entire control on or off independently for specific pages. Is
-> there a way to control the visibility of a specific list item?
->
-> For example the xml control displays an unordered list with 5 list
-> items. So, on certain pages, I want to only show 4 of the 5 list
-> items. Based on your example, I'd need a different id for every <li>
-> tag. How can I set an id for each <li> tag? Is there a way to do
-> that? Can I modify my xml/xslt pages to add the id?
->
-> I really appreciate your help.
->
-> -D-
->
-> ->-> TransformSource="../topnavigationbar.xslt"
->-> not
->---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
D

-D-

Hi Michael,

Yes, here is a link to download the sample files:
http://www.dwayneepps.com/download.asp

I've included the xml file that defines the sitemap navigation (there might
be a better way to structure the hierarchy).
The xslt file that defines the top navigation menu.
The user control (topnavbar.ascx) that contains the xml control
and the index.aspx file that holds the different user controls.

I'm using my index file as a template, which I can duplicate for any page in
the site and turn on or off the different user controls depending on what
navigation I want to show for a specific page.

Also, as in my previous post, I want to control the individual menu items
and not just the control itself.

If I need to include any additional files, just let me know.

Thanks again for taking the time to help me out. I'm still very new to
asp.net and learning my way around.

Regards,
-D-
 
M

Michael Nemtsev

Hello -D-,

What the problem with adding ID tag for the <LI>?


-> Hi Michael,
->
-> Yes, here is a link to download the sample files:
-> http://www.dwayneepps.com/download.asp
-> I've included the xml file that defines the sitemap navigation (there
-> might
-> be a better way to structure the hierarchy).
-> The xslt file that defines the top navigation menu.
-> The user control (topnavbar.ascx) that contains the xml control
-> and the index.aspx file that holds the different user controls.
-> I'm using my index file as a template, which I can duplicate for any
-> page in the site and turn on or off the different user controls
-> depending on what navigation I want to show for a specific page.
->
-> Also, as in my previous post, I want to control the individual menu
-> items and not just the control itself.
->
-> If I need to include any additional files, just let me know.
->
-> Thanks again for taking the time to help me out. I'm still very new
-> to asp.net and learning my way around.
->
-> Regards,
-> -D-
-> ->-> not
->---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
D

-D-

each <li> tag would need a different id. The xslt file generates the
unordered list, so I wasn't sure how to specify a different id for each <li>
tag so I can control it independently.
 
M

Michael Nemtsev

Hello -D-,

Why not to put in LI's ID page url/title? Thus your LI's will be unique

-> each <li> tag would need a different id. The xslt file generates the
-> unordered list, so I wasn't sure how to specify a different id for
-> each <li> tag so I can control it independently.
->
-> ->-> not
->---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top