J
Justin M. Keyes
Hi,
I have a custom web server control, specifically a composite control,
that includes an image button. The image button takes an ImageUrl
property that renders at _runtime_, but at design-time the image does
not render unless the user chooses an image.
I would like to display a default image at design-time (or _at_least_
reduce the size of the "missing image" icon that Visual Studio
displays--it is too big**[see footnote]**).
The ImageUrl property can only point to a path, obviously, which means
I must depend on the user to have an image at a certain path. Also, I
cannot access the Request object (thus neither the
Request.ApplicationPath) at design-time, so I can't even get a valid
path at design-time anyways.
Therefore, I would like to use an embedded resource (an image included
in the Visual Studio project, with 'Build Action' marked as "Embedded
Resource") at runtime.
But from what I can tell, System.Web.UI.Design.ControlDesigner only
allows me to really affect the HTML at design-time via
GetDesignTimeHtml(). But I cannot display an embedded resource with
HTML...
Here are relevant parts of my code:
---------------------------------------------
public class PopupCalendar : System.Web.UI.WebControls.WebControl,
INamingContainer {
private TextBox textBox;
private Image image;
....
protected override void CreateChildControls() {
this.Controls.Clear();
textBox = new TextBox();
this.Controls.Add(textBox);
textBox.ID = "TextBox";
image = new Image();
this.Controls.Add(image);
image.ID = "Image";
}
....
}
---------------------------------------------
public class PopupCalendarDesigner : WebDesign.ControlDesigner {
public override string GetDesignTimeHtml () {
PopupCalendar popcal = (PopupCalendar)this.Component;
return "<input type=\"text\" style=\"width: " + popcal.Width + "px\"
/><img style=\"width: 16px; height: 16px;\">";
}
}
---------------------------------------------
**[footnote]**
I have tried putting "image.Width = Unit.Pixel(16); image.Height =
Unit.Pixel(16);" in CreateChildControls(), but that means that only
16x16 images can be used, because this affects _both_ design-time and
run-time.
Thank you very much for your help!
- Justin
I have a custom web server control, specifically a composite control,
that includes an image button. The image button takes an ImageUrl
property that renders at _runtime_, but at design-time the image does
not render unless the user chooses an image.
I would like to display a default image at design-time (or _at_least_
reduce the size of the "missing image" icon that Visual Studio
displays--it is too big**[see footnote]**).
The ImageUrl property can only point to a path, obviously, which means
I must depend on the user to have an image at a certain path. Also, I
cannot access the Request object (thus neither the
Request.ApplicationPath) at design-time, so I can't even get a valid
path at design-time anyways.
Therefore, I would like to use an embedded resource (an image included
in the Visual Studio project, with 'Build Action' marked as "Embedded
Resource") at runtime.
But from what I can tell, System.Web.UI.Design.ControlDesigner only
allows me to really affect the HTML at design-time via
GetDesignTimeHtml(). But I cannot display an embedded resource with
HTML...
Here are relevant parts of my code:
---------------------------------------------
public class PopupCalendar : System.Web.UI.WebControls.WebControl,
INamingContainer {
private TextBox textBox;
private Image image;
....
protected override void CreateChildControls() {
this.Controls.Clear();
textBox = new TextBox();
this.Controls.Add(textBox);
textBox.ID = "TextBox";
image = new Image();
this.Controls.Add(image);
image.ID = "Image";
}
....
}
---------------------------------------------
public class PopupCalendarDesigner : WebDesign.ControlDesigner {
public override string GetDesignTimeHtml () {
PopupCalendar popcal = (PopupCalendar)this.Component;
return "<input type=\"text\" style=\"width: " + popcal.Width + "px\"
/><img style=\"width: 16px; height: 16px;\">";
}
}
---------------------------------------------
**[footnote]**
I have tried putting "image.Width = Unit.Pixel(16); image.Height =
Unit.Pixel(16);" in CreateChildControls(), but that means that only
16x16 images can be used, because this affects _both_ design-time and
run-time.
Thank you very much for your help!
- Justin