Monday, March 12, 2012

what is the difference

what is the difference between an html image control that is set to run=server and a basic asp image control?I guess that in your CodeBehind you can control your HTML Image Control... That is you could access it properties and such.
That's a good question, given that they both end up rendering an <img> tag.

The difference is that the asp:Image control is designed to be consistent with the other server controls.

For example, with the HTML image, we specify the image file with src="http://pics.10026.com/?src=image/logo.gif".
With the asp:Image, we specify the image file with ImageUrl="image/logo.gif".
The result of course is the same.

However, the asp:Image's use of the ImageUrl means it is consistent with how we'd work with an asp:HyperLink control or an asp:ImageButton control. So:
MyImage.ImageUrl = "image/logo.gif"
MyHyperLink.ImageUrl = "image/link.gif"
MyImageButton.ImageUrl = "image/button.gif"

To do the same with HTML controls means using completely different tags and attributes.

But with the server controls, they all use similar or identical properties and methods.

So the difference is just a matter of consistency.

0 comments:

Post a Comment