What’s so important about "paths"?October, 2004A young developer was struggling with the hardest problem on earth. He was trying to show an image in two different web pages. The image was appearing on one web page, and, the same was not appearing on another! Following was the HTML element he was struggling with:<img id="imgAction" src="images/action.jpg" />Guess what, the poor developer was none but me!I still can remember, I had troubles with setting appropriate paths for different elements(Images/documents/videos etc) in the web pages. I used to struggle with putting download links in the pages and show images and/video files (Which I still have to do) by using different HTML elements or server controls along with setting their different attributes (href, src etc) values. It sounds funny, but, often I used to find myself in situations where the images were appearing in one page and not appearing in another Or, the download links were braking often. I wondered why! That was a great mastery to me in those early days, along with lots of other mysterious things I was going through each day. Its obvious, I didn’t have clear understanding about setting the href or src property values appropriately for the HTML and Asp.net server controls, and that’s why I had to suffer. Its been long, those days are gone. I grew up a little, and, I don’t have any problem with those mysterious paths these days. Still today, I see lots of newbies struggle with these path related issues (See here and here) and these hurts. So, I decided to uncover those “path mysteries” for the absolute beginners (Like me in October 2004) so that, they don’t have to waste a minute for setting appropriate path values for Asp.net pages. Please note that, this article doesn’t discuss any “rocket science”. All It talks about is some plain old basic stuff and great chance is, you already are a master of the subject matter. But, I often love to go back to the basics, and try to sharpen my knowledge, to make myself a little better then yesterday. Who knows? someone might just feel the same. If you are one of those, feel free to proceed. What did I mean by "Path"?In an Asp.net applications, we either use HTML elements or Server controls for adding several elements (Such as, Image, HyperLink etc.) in the pages. For an <img> element, we need to set an “src” attribute value (Usually, in terms of relative URL path) that points to an image within the application in general. Also, for an anchor <a> element, we need to set an “href” value that points to a resource (Be it a page or an image or a downloadable zip file) within the application directory. These are the attributes that I am referring as “path” in general. Read more: Codeproject
0 comments:
Post a Comment