I'm hoping there's a simple way to do this. I need to show a dummy image in
an asp image object if the file is missing. Here's my asp.net 2.0 markup:
<asp:Image ID="imgGrad" runat="server" BorderColor="Di mGray"
BorderStyle="So lid" BorderWidth="1p x" Height="120px" ImageUrl='<%#
"~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>' ToolTip="Click to
enlarge" /></td>
"GradPhotoFileN ame" is stored in a field in a table. If the file name stored
in the table is "JeffJones. jpg" but there is no "JeffJones. jpg" file in the
"~/Images/ClassmatePics/" folder then I have a dummy jpg image that I want
to show ("MissingPhoto. jpg").
I'm hoping there's an easy way to do that maybe in the EVAL code but I don't
know how. Can someone help me out?
Thanks,
Keith
Jun 27 '08
10 1674
Actually the easiest and most efficient way is to do it with javascript on
the client side, just do this on your Page_Load routine:
imgGrad.Attribu tes("onerror") = "this.src='<dum my image relative path>;'"
That will cause the user's browser to load the dummy image if it doesn't
find the original.
Hope that helps,
Fernando Rodriguez, MCP
"S.M. Altaf [MVP]" <sm*****@omgplz dntspammekthxba imsn.comwrote in message
news:3F******** *************** ***********@mic rosoft.com...
Do this from the codebehind. You have the value of "GradPhotoFileN ame",
you can check if System.Io.File. Exists() and if it doesn't, set the
.ImageUrl property of your imgGrad image to your dummy image URL. I do
not know how you're binding your image to the data though, but how you
assign the values in the codebehind will depend on the method you're
using.
--
---------------------------------------------------
S.M. Altaf [MVP] http://www.mendhak.com/
"Keith G Hicks" <kr*@comcast.ne twrote in message
news:#m******** ******@TK2MSFTN GP04.phx.gbl...
>I appreciate the hint but being pretty new to all of this (asp.net) I have no idea how to go about doing that. I'm fine with VB and can create subs and functions just fine so if that's what you mean I can do that part I guess but implementing it in my markup below is not remotely clear to me. I need as much help as possible.
THanks,
Keith
"Peter Bromberg [C# MVP]" <pb*******@nosp ammaam.yahoo.co mwrote in message news:30******* *************** ************@mi crosoft.com...
>>Probably the easiest way is to call a protected method that accepts type object (e.g., Eval("GradPhoto FileName") ) -- and returns the proper
string
>>url to the image, or the alternate image url. --Peter "Keith G Hicks" <kr*@comcast.ne twrote in message news:eZ****** ********@TK2MSF TNGP05.phx.gbl. .. I'm hoping there's a simple way to do this. I need to show a dummy image in an asp image object if the file is missing. Here's my asp.net 2.0
markup:
>> <asp:Image ID="imgGrad" runat="server" BorderColor="Di mGray" BorderStyle="S olid" BorderWidth="1p x" Height="120px" ImageUrl='<%# "~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>' ToolTip="Cli ck to enlarge" /></td>
"GradPhotoFile Name" is stored in a field in a table. If the file name stored in the table is "JeffJones. jpg" but there is no "JeffJones. jpg" file in the "~/Images/ClassmatePics/" folder then I have a dummy jpg image that I
want
>to show ("MissingPhoto. jpg").
I'm hoping there's an easy way to do that maybe in the EVAL code but I don't know how. Can someone help me out?
Thanks,
Keith This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: robcarlton |
last post by:
hi everybody
I've written this function to make a list of all of an objects
attributes and methods (not for any reason, I'm just learning)
def list_members(obj)
l = dir(obj)
return map(lambda x : eval('obj.'+x), l)
but I get an error saying that obj isn't defined. As I understand it
eval has access to the current local namespace, which does contain
|
by: HikksNotAtHome |
last post by:
This is a very simplified example of an Intranet application. But, is there an
easier (or more efficient) way of getting the decimal equivalent of a fraction?
The actual function gets the select values, this one is a simplified version
where its passed.
function checkIt(selVal){
valueInDec1 = eval(selVal);
//do some calculations here with valueInDec1
}
|
by: Stanley J Mroczek |
last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ?
<Columns>
<asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True"
HeaderText="Option Description"></asp:BoundColumn>
<asp:TemplateColumn runat="server" HeaderText="Id Type Option" ">
<itemtemplate>
<asp:label runat="server" Text='<%# DataBinder.Eval(Container.DataItem,
"TypeOption") %>' />
<asp:label runat="server" ID="LlbTypeOption" Visible=False...
|
by: J. J. Cale |
last post by:
given that I have a js file included which is written programatically and I
can't change it. I would like to know how to do the following using
something other than the deprecated eval().
whats in the js file
var numArrays=something;
var data0 = new Array();
data0.name="name";
data0.data="some data";
var data1 = new Array();
data1.name="another name";
|
by: Baldy |
last post by:
really tricky one here.
I want to be able to call a function but the function name is in a variable.
The code is a security module that is querying a table that stores names of
functions, forms, reports etc and what access certain groups have. forms,
reports etc work fine as I use
DoCmd.OpenForm objectToRunName
but how do I do it when "objectToRunName" has a function name?
| |
by: Steve Richter |
last post by:
I have a public variable ( "mZipServiceUrl" ) in my code behind class
that I am able to substitute into the HTML of the .aspx file:
<span onclick="WindowOpen('<%=mZipServiceUrl%>')"
style="text-decoration:underline;cursor:hand;color:red;">
<%=mZipServiceUrl%>
</span>
but in the same page, I cant substitute the same variable into a user
control:
|
by: Nathan Sokalski |
last post by:
I am using a DataSet as the DataSource of a DataList in my code. The SQL
used to get the data from the database begins with:
SELECT
members.organization,artists.artist,artists.email,artists.website,members.email
FROM members INNER JOIN artists ON members.memberid=artists.memberid WHERE
Notice that both tables involved in the SELECT statement have a field named
|
by: malice |
last post by:
I have been searching the internet for 12+ hours on how to do this. At this point I'm about to give up. I am using VB .Net 2.0 with the enterprise library jan 2006 release. This is my first time using it and I'm a novice to .Net. I am using the data access quickstart solution and I just started adding my own forms and stuff to it. I got my sql query to work and populate a dataview on my new form with just a few lines of code. Here is my problem...
|
by: gouraud |
last post by:
Hello,
I'm working on Visual Web Developper (ASPX with C# code Behind)
I would like to fill a DataList with items using this format (with as
item as elements) :
"file - element", example : "MyTitle - Theme A"
The problem is that labels, which are binded to theses fields, return
me an error :
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |