本文介绍了xml控件可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如何打开或关闭xml控件的可见性? <%@ Control Language =" c#" AutoEventWireup =" false" Codebehind =" TopNavBar.ascx.cs" Inherits =" compass.user_controls.TopNavBar" TargetSchema =" http://schemas.microsoft.com/intellisense/ie5"%> < table CELLSPACING = QUOT; 0" CELLPADDING = QUOT; 0" border =" 0"> < colgroup span =" 1"对齐= QUOT;左" width =" 50%"> < / colgroup> < colgroup span =" 1"对齐= QUOT;右" 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"名称= QUOT; frmSearch" action =" search.asp" method =" post"> 搜索< input type =" text"大小= QUOT; 25"命名= QUOT; txtQuery"> < A href =" javascript :document.frmSearch.submit()"> < IMG src ="图像/ go.gif"对齐= QUOT; absMiddle" border =" 0">< / A> < / form> < / td> < / tr> < / table> 这是背后的代码: namespace compass.user_controls { 使用System; 使用System.Collections; 使用System.Data; 使用System.Drawing; 使用System.Web; 使用System.Web.UI.WebControls; 使用System.Web .UI.HtmlControls; 使用System.Xml; 使用compass.ClassFiles; ///< summary> /// TopNavBar的摘要说明。 ///< / summary> 公共类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) { //用户代码初始化th e page这里 } #region Web表单设计器生成的代码 覆盖protected void OnInit(EventArgs e ) { // // CODEGEN:ASP.NET Web窗体设计器需要此调用。 // InitializeComponent(); base.OnInit(e); } ///< summary> /// Designer支持所需的方法 - 不要使用代码编辑器修改 ///此方法的内容。 ///< / summary> private void InitializeComponent() { this.Load + = new System.EventHandler(this.Page_Load); } #endregion } } 此外,xslt文件生成无序列表。有没有办法在后面的代码中为其中一个列表项设置 可见性? 例如,如果有五个列表项是显示并且我想隐藏其中一个项目的 可见性,有没有办法做到这一点?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"> <Ahref="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 codeoverride 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 thevisibility 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 thevisibility of one of the items, is there a way to do this?推荐答案 --- WBR, Michael Nemtsev ::博客: http://spaces.msn.com/laflour 有时一个人仍忠于某一事业,只因为它的反对者不会因为b $ b不再是平淡无奇的。 (c)Friedrich Nietzsche---WBR,Michael Nemtsev :: blog: http://spaces.msn.com/laflour"At times one remains faithful to a cause only because its opponents do notcease to be insipid." (c) Friedrich Nietzsche 这篇关于xml控件可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-31 00:06