How to add an image to web user control?
-
Hi all, I created a control extends textbox control and I named it MyTextBox. In render method, I added an image beside the textbox like: <img src='...'>. However, when I apply it to my webpage. The image doesn't appear (The image's url depend on webapplication project). So, I want to ask you how I embed that image in my control (dll file). Thx!
-
Hi all, I created a control extends textbox control and I named it MyTextBox. In render method, I added an image beside the textbox like: <img src='...'>. However, when I apply it to my webpage. The image doesn't appear (The image's url depend on webapplication project). So, I want to ask you how I embed that image in my control (dll file). Thx!
+ To embed the image in the control assembly, you can simply add the image file to the control project, then set the BuildAction[^] property of the file to the
Embedded Resource
. + To get the URL to the embeded image, you can use the GetWebResourceUrl [^] method. -
+ To embed the image in the control assembly, you can simply add the image file to the control project, then set the BuildAction[^] property of the file to the
Embedded Resource
. + To get the URL to the embeded image, you can use the GetWebResourceUrl [^] method.Thank you for your reply! However, GetWebResourceUrl: This method is new in the .NET Framework version 2.0. Now I tell you the detail: I want to write a datetimepicker, it has a textbox and an image at beside. So that I create a web control extended textbox. I don't care about the image of the assembly, I just pay attention to the image beside the textbox. I want when I compile it into dll file, It will be a dependent control. The image beside the textbox doesn't belong to any projects. any suggestion?