Hola a todos,
tengo un problema con un componente barra de progreso que encontré en internet y que he traducido al c#. El problema es que las propiedades públicas que he puesto en el componente no son visibles en la parte servidora. Pongo el código a contunuación:
<%@ Control Language="C#" ClassName="progreso" %>
<script runat="server">
private Single percentComplete = 0; // 0.00% to 100.00%
private String style = "ieesque"; // {html|IEESQUE|bluegrey|ie|classic}
private Int32 width = 150; // in pixels
public Single PorcentajeCompletado
{
get
{
return percentComplete;
}
set
{
percentComplete = value;
}
}
public String Estilo
{
get
{
return style;
}
set
{
style = value;
}
}
public Int32 Width
{
get
{
return width;
}
set
{
width = value;
}
}
public void Page_Load(Object Source , EventArgs e){
String strProgressBarHtml;
switch (style.ToLower()){
case "html":
strProgressBarHtml = BuildProgressBarHtmlTable(percentComplete, width);
break;
case "ie" :
strProgressBarHtml = BuildProgressBarChunked(percentComplete, style, width);
break;
case "classic": // chunked styles
strProgressBarHtml = BuildProgressBarChunked(percentComplete, style, width);
break;
default : //' smooth styles ("bluegrey", "ieesque")
strProgressBarHtml = BuildProgressBarSmooth(percentComplete, style, width);
break;
}
litProgressBar.Text = strProgressBarHtml;
}
public String BuildProgressBarHtmlTable(Single sglPercentComplete ,Int32 intWidth){
Int32 intBarLength;
StringBuilder sbDisplayHtml = new StringBuilder();
if (0 <= sglPercentComplete && sglPercentComplete <= 100)
{
// Compensate for the width of the table border
intBarLength = intWidth - 4;
sbDisplayHtml.Append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\"><tr><td>");
sbDisplayHtml.Append("<table width=\"" + intBarLength + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
sbDisplayHtml.Append("<tr><td width=\"" + System.Math.Round(sglPercentComplete * intBarLength / 100) + "\" style=\"background-color:#0000FF\"> </td><td> </td></tr>");
sbDisplayHtml.Append("</table>");
sbDisplayHtml.Append("</td></tr></table>");
}
return sbDisplayHtml.ToString();
}
public String BuildProgressBarChunked(Single sglPercentComplete ,String strStyleName ,Int32 intWidth )
{
String strImageBaseName;
Int32 intImageHeight;
Int32 intImageLeftWidth;
Int32 intImageRightWidth;
Int32 intImageChunkWidth;
Int32 intChunksTotal;
Int32 intChunksFilled;
StringBuilder sbDisplayHtml = new StringBuilder();
switch(strStyleName.ToLower()){
case "classic" :
strImageBaseName = "../barraProgreso/images/progress_classic_";
intImageHeight = 16;
intImageLeftWidth = 2;
intImageRightWidth = 2;
intImageChunkWidth = 10;
break;
default : // "ie"
strImageBaseName = "../barraProgreso/images/progress_ie_";
intImageHeight = 17;
intImageLeftWidth = 4;
intImageRightWidth = 4;
intImageChunkWidth = 8;
break;
}
// Since we no longer have the luxury of changing the parameters based
// on the type of bar requested, we need to calculate the number of chunks
// to display based on the style info and the amount of space (pixels) we
// have to display the bar. Using this method we should always get as
// many chunks as we can fit without going over the allotted space.
intChunksTotal = Convert.ToInt32((intWidth - (intImageLeftWidth + intImageRightWidth)) / intImageChunkWidth);
if ( (0 <= sglPercentComplete) && (sglPercentComplete <= 100) )
{
intChunksFilled = Convert.ToInt32(System.Math.Round(sglPercentComple te * intChunksTotal / 100));
sbDisplayHtml.Append("<img src=\"" + strImageBaseName + "left.gif\" border=\"0\" height=\"" + intImageHeight + "\" width=\"" + intImageLeftWidth + "\">");
for(int i = 1 ; i < intChunksTotal ; i++)
{
if ( i <= intChunksFilled )
{
sbDisplayHtml.Append("<img src=\"" + strImageBaseName + "full.gif\" border=\"0\" height=\"" + intImageHeight + "\" width=\"" + intImageChunkWidth + "\" alt=\"" + sglPercentComplete + "%\">");
}
else
{
sbDisplayHtml.Append("<img src=\"" + strImageBaseName + "empty.gif\" border=\"0\" height=\"" + intImageHeight + "\" width=\"" + intImageChunkWidth + "\" alt=\"" + (100 - sglPercentComplete) + "%\">");
}
}
sbDisplayHtml.Append("<img src=\"" + strImageBaseName + "right.gif\" border=\"0\" height=\"" + intImageHeight + "\" width=\"" + intImageRightWidth + "\">");
}
return sbDisplayHtml.ToString();
}
public String BuildProgressBarSmooth(Single sglPercentComplete ,String strStyleName ,Int32 intWidth )
{
String strImageBaseName;
Int32 intImageHeight;
Int32 intImageLeftWidth;
Int32 intImageRightWidth;
Int32 intBarLength;
StringBuilder sbDisplayHtml = new StringBuilder();
switch (strStyleName.ToLower()){
case "bluegrey" :
strImageBaseName = "../barraProgreso/images/progress_bluegrey_";
intImageHeight = 16;
intImageLeftWidth = 3;
intImageRightWidth = 3;
break;
default : // "ieesque"
strImageBaseName = "../barraProgreso/images/progress_ie7_";
intImageHeight = 17;
intImageLeftWidth = 4;
intImageRightWidth = 4;
break;
}
if( (0 <= sglPercentComplete) && (sglPercentComplete <= 100) )
{
// Compensate for the width of the two end images
intBarLength = intWidth - (intImageLeftWidth + intImageRightWidth);
sbDisplayHtml.Append("<img src=\"" + strImageBaseName + "left.gif\" border=\"0\" height=\"" + intImageHeight + "\" width=\"" + intImageLeftWidth + "\">");
sbDisplayHtml.Append("<img src=\"" + strImageBaseName + "full.gif\" border=\"0\" height=\"" + intImageHeight + "\" width=\"" + System.Math.Round(sglPercentComplete * intBarLength / 100) + "\" alt=\"" + sglPercentComplete + "%\">");
sbDisplayHtml.Append("<img src=\"" + strImageBaseName + "empty.gif\" border=\"0\" height=\"" + intImageHeight + "\" width=\"" + (intBarLength - System.Math.Round(sglPercentComplete * intBarLength / 100)) + "\" alt=\"" + (100 - sglPercentComplete) + "%\">");
sbDisplayHtml.Append("<img src=\"" + strImageBaseName + "right.gif\" border=\"0\" height=\"" + intImageHeight + "\" width=\"" + intImageRightWidth + "\">");
}
return sbDisplayHtml.ToString();
}
</script>
<asp:Literal id="litProgressBar" runat="server" />
El problema está al acutalizar el valor de la barra en el lado servidor de la forma:
barraProgreso.PorcentajeCompletado = intPorcentaje;
me dice que PorcetajeCompletado no existe en el componente barraProgreso.
Alguna idea?