All pastes #2057025 Raw Edit

Unnamed

public text v1 · immutable
#2057025 ·published 2011-05-11 20:47 UTC
rendered paste body
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;

public class AdvancedCheckBoxList : CheckBoxList
{


	protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
	{
		writer.Write("<div class=\"celdamarca\">");


		CheckBox checkbox = new CheckBox();
		checkbox.ID = ClientID + "$" + repeatIndex.ToString();
		checkbox.AutoPostBack = AutoPostBack;
		checkbox.Checked = Items(repeatIndex).Selected;
		checkbox.TextAlign = TextAlign;

		string initialText = Items(repeatIndex).Text;
		string[] cadenas = initialText.Split(';');
		//img: images/milogo.gif, 210, 145  <----- ; ----->  text: mi texto

		writer.Write("<label for=\"" + ClientID + "_" + repeatIndex.ToString() + "\">");
		foreach (string m in cadenas) {
			string[] pares = m.Split(':');
			if ((pares.Length > 0)) {
				if (pares[0] == "img") {
					Image img = new Image();
					string[] atributosImg = pares[1].Split(',');
					img.ImageUrl = atributosImg[0];
					if (atributosImg.Length > 1 && ((atributosImg[1] != null)) && (atributosImg[1] != string.Empty)) {
						img.Width = Int32.Parse(atributosImg[1]);
					}
					if (atributosImg.Length > 2 && ((atributosImg[2] != null)) && (atributosImg[2] != string.Empty)) {
						img.Height = Int32.Parse(atributosImg[2]);
					}
					img.RenderControl(writer);
					writer.Write("<br />");

				} else if (pares[0] == "text") {
					Label lb = new Label();
					lb.Text = pares[1];
					lb.RenderControl(writer);
					writer.Write("<br />");
				}
			}
		}
		writer.Write("</label>");
		checkbox.RenderControl(writer);

		writer.Write("</div>");
	}
}