I have same compiled user controls (.ascx) and I don't have the code behind. This user controls have some images and the source is defined in code behind. Do you have any idea how I can change the source path images?
Asked
Active
Viewed 882 times
2 Answers
0
The dirty way would be to overwrite the path using jQuery.
The clean way would be a new Control which implements the original one. Now you should be able to overwrite the original functionality.
Here's a little example:
public partial class NewControl : OriginalControl
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
imageControl.Attribute = "new/path/to/img.jpg";
}
}

Fabian
- 394
- 1
- 6
0
Just override an event in the markup, like this:
<script runat="server">
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Image1.ImageUrl = "~/images/some_image.jpg";
}
</script>

James Johnson
- 45,496
- 8
- 73
- 110