當前位置: 首頁>>代碼示例>>C#>>正文


C# CheckBox.RenderControl方法代碼示例

本文整理匯總了C#中System.Web.UI.WebControls.CheckBox.RenderControl方法的典型用法代碼示例。如果您正苦於以下問題:C# CheckBox.RenderControl方法的具體用法?C# CheckBox.RenderControl怎麽用?C# CheckBox.RenderControl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.UI.WebControls.CheckBox的用法示例。


在下文中一共展示了CheckBox.RenderControl方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RenderContents

		/// <summary>
		/// 
		/// </summary>
		/// <param name="writer"></param>
		/// <author>
		/// Created by Iulian Iuga; 30 December, 2002
		/// </author>		
		protected void RenderContents( HtmlTextWriter writer )
		{
			TableRow _tr = new TableRow();
			TableCell _td = new TableCell();

			_tr.RenderBeginTag( writer );
			
			// apply CssClass for current element
			if( _element.TreeWeb.DefaultElementCssClass.Length > 0 )
				_td.CssClass = _element.TreeWeb.DefaultElementCssClass;
			if( _element.CssClass.Length > 0 )
				_td.CssClass = _element.CssClass;

			//_td.Style.Add( "display", "none" );
			_td.Attributes.Add( "nowrap", "yes" );
			_td.RenderBeginTag( writer );

			// render a &nbsp; at the begining of each element
			writer.Write( "&nbsp;" );

			// render element indentation based on element level
			string _indentation = "";
      int nIndentationPerStep = _element.TreeWeb.Indentation;
			for( int index = 0; index < (_element.Level * nIndentationPerStep); index++ )
				_indentation += _indentationStep;
			writer.Write( _indentation );

			// render the expand/collapse link if the element has child elements and is expandable.
			if( _element.HasElements )
			{
				HyperLink _link = new HyperLink();
				Image _image = new Image();

        if( _element.TreeWeb.Expandable && _element.Expandable )
        {
          if( _element.IsExpanded )
          {
            _link.Text = _expcol[1];
            if( _element.TreeWeb.ExpandedElementImage.Length > 0 )
              _image.ImageUrl = _element.TreeWeb.ExpandedElementImage;
          }
          else
          {
            _link.Text = _expcol[0];
            if( _element.TreeWeb.CollapsedElementImage.Length > 0 )
              _image.ImageUrl = _element.TreeWeb.CollapsedElementImage;
          }
        }

				string scriptCode = "javascript:";
				scriptCode += _element.TreeWeb.Page.GetPostBackEventReference( _element.TreeWeb, _element.ID );
				_link.NavigateUrl = scriptCode;

				if( _image.ImageUrl.Length > 0 )
				{
					_link.RenderBeginTag( writer );
					_image.RenderControl( writer );
					_link.RenderEndTag( writer );
				}
				else
					_link.RenderControl( writer );

				_image = null;
				_link = null;
				writer.Write( "&nbsp;" );
			}

			// render checkbox
			if( _element.TreeWeb.CheckBoxes || _element.CheckBox )
			{
				CheckBox _checkbox = new CheckBox();
				
				_checkbox.ID = _element.ID + TreeElement._separator + TreeElement._checkboxIDSufix;
				_checkbox.RenderControl( writer );

				_checkbox = null;
				
				// write a non-breaking space before the element text
				writer.Write( "&nbsp;" );
			}

			// render element's image if it has one
			if( _element.ImageIndex > -1 )
			{
				ElementImage _elementImage = _element.TreeWeb.ImageList[_element.ImageIndex];
				if( _elementImage != null )
				{
					Image _image = new Image();

					_image.ImageUrl = _elementImage.ImageUrl;
					_image.RenderControl( writer );

					_image = null;
//.........這裏部分代碼省略.........
開發者ID:dineshkummarc,項目名稱:Portal-V2.8.1,代碼行數:101,代碼來源:TreeElementWriter.cs

示例2: RenderNodeCheckbox

        /// <summary>
        ///
        /// </summary>
        /// <param name="writer"></param>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[jbrinkman]	5/6/2004	Created
        /// </history>
        protected void RenderNodeCheckbox( HtmlTextWriter writer )
        {
            if( _Node.DNNTree.CheckBoxes )
            {
                CheckBox _checkbox = new CheckBox();
                _checkbox.ID = _Node.ID + TreeNode._separator + TreeNode._checkboxIDSufix;
                _checkbox.Checked = _Node.Selected;
                string strJS = "";
                if( _Node.JSFunction.Length > 0 )
                {
                    if( _Node.JSFunction.EndsWith( ";" ) == false )
                    {
                        _Node.JSFunction += ";";
                    }
                    strJS += _Node.JSFunction;
                }
                if( _Node.DNNTree.JSFunction.Length > 0 )
                {
                    if( _Node.DNNTree.JSFunction.EndsWith( ";" ) == false )
                    {
                        _Node.DNNTree.JSFunction += ";";
                    }
                    strJS += _Node.DNNTree.JSFunction;
                }

                string strClick = ClientAPI.GetPostBackClientHyperlink( _Node.DNNTree, _Node.ID + ClientAPI.COLUMN_DELIMITER + "Click" ).Replace( "javascript:", "" ) + ";";
                string strCheck = ClientAPI.GetPostBackClientHyperlink( _Node.DNNTree, _Node.ID + ClientAPI.COLUMN_DELIMITER + "Checked" ).Replace( "javascript:", "" ) + ";";
                if( _Node.Selected == false )
                {
                    if( strJS.Length > 0 )
                    {
                        strJS = "if (eval(\"" + strJS.Replace( "\"", "\"\"" ) + "\") != false) ";
                        strJS += strClick + " else " + strCheck;
                    }
                    else
                    {
                        strJS += strClick;
                    }
                }
                else
                {
                    strJS = strCheck;
                }

                //_checkbox.Attributes.Add("onclick", ClientAPI.GetPostBackClientHyperlink(_Node.DNNTree, _Node.ID & ",Unchecked"))
                //Else
                _checkbox.Attributes.Add( "onclick", strJS );
                //End If
                _checkbox.RenderControl( writer );
                _checkbox = null;
                writer.Write( "&nbsp;", null );
            }
        }
開發者ID:huayang912,項目名稱:cs-dotnetnuke,代碼行數:62,代碼來源:TreeNodeWriter.cs


注:本文中的System.Web.UI.WebControls.CheckBox.RenderControl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。