Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I'm new to ASP.NET and C#. I was wondering if anyone would be able to help me in determining how I can display a certain image (alert, error, or success) in a cell of the middle column within a table based on a variable. I believe this would need to be done through markup, but have not been able to figure it out with some of the articles and discussion i've found. Thanks!

My variables and their associated values are...
epsServerState = (online or offline)
epsFtpState = (running or stopped)
epsSpoolerState = (running or stopped)
epsEpicState = (running or stopped)


ASP.NET
<table style="font-size: medium; font-family: fixedsys;" title="EPS1" 
            class="table">
            <tr>
                <td class="title" 
                    
                    
                    style="font-weight: bolder; font-variant: small-caps; text-transform: capitalize; color: #000080; border-collapse: collapse; empty-cells: hide; caption-side: top; font-size: large;">
                    EPS</td>
                <td class="gfx" 
                    
                    
                    
                    style="font-weight: bolder; font-variant: small-caps; text-transform: capitalize; color: #000080; border-collapse: collapse; empty-cells: hide; caption-side: top; font-size: large;">
                     </td>
                <td>
                </td>
            </tr>
            <tr>
                <td class="headings" align="right">
                    Server Status:</td>
                <td class="gfx" align="right">
                    <img class="style28" src="Images/success.png" /></td>
                <td align="justify" class="results">
                    <asp:Label ID="epsServerLabel" runat="server" CssClass="results"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="headings" align="right">
                    FTP Service:</td>
                <td class="gfx" align="right">
                    <img class="style28" src="Images/error.png" /></td>
                <td align="justify" class="results">
                    <asp:Label ID="epsFtpLabel" runat="server" CssClass="results"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="headings" align="right">
                    Spooler Service:</td>
                <td class="gfx" align="right">
                    <img class="style28" src="Images/alert.png" /></td>
                <td align="justify" class="results">
                    <asp:Label ID="epsSpoolerLabel" runat="server" CssClass="results"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="headings" align="right">
                    Epic Service:</td>
                <td class="gfx" align="right">
                    <img class="style28" src="Images/success.png" /></td>
                <td align="justify" class="results">
                    <asp:Label ID="epsEpicLabel" runat="server" CssClass="results"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="headings" align="right">
                    Processing:</td>
                <td class="gfx" align="right">
                    <img class="style28" src="Images/error.png" /></td>
                <td align="justify" class="results">
                    <asp:Label ID="epsProcessingLabel" runat="server" CssClass="results"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="headings" align="right">
                    Last Processed:</td>
                <td class="gfx" align="right">
                    <img class="style28" src="Images/alert.png" /></td>
                <td align="justify" class="results">
                    <asp:Label ID="epsProcessedLabel" runat="server" CssClass="results"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="headings" align="right">
                    Last Failed:</td>
                <td class="gfx" align="right">
                    <img class="style28" src="Images/success.png" /></td>
                <td align="justify" class="results">
                    <asp:Label ID="epsFailedLabel" runat="server" CssClass="results"></asp:Label>
                </td>
            </tr>
        </table>
Posted
Comments
vivektiwari97701 2-Aug-12 3:54am    

[^]

You just need to add an image control, and then set it's URL, the easiest way is to call a code behind method that gets the parameters that need checking, and then returns the correct image URL based on those values.

If you use an img tag, you can still set the src using a code behind call.
 
Share this answer
 
Instead of img tag use image control
C#
<asp:image id="imgServerOnline" runat="server" alt="serverstatus" xmlns:asp="#unknown"></asp:image>

or if you still want img tag then add id & runat attribut to img tag. Set its src property to image url from codebehind.

On server side in code behind
add this code
C#
Bool IsServerOnline;
//Code to set value to variable
if(IsServerOffline)
{
imgServerOnline.ImageUrl="Images/Online.png"
}
else
{
imgServerOnline.ImageUrl="Images/Offline.png"
}
 
Share this answer
 
v2
Thanks for the suggestions. I ran across another article and was able to resolve this problem by doing the following.

HTML
string epsFtpState = shell.Runspace.SessionStateProxy.GetVariable("epsFtpState").ToString();

if (epsFtpState.Contains(epsFtpState, "Stopped")){
	Image epsFTPimg = new Image();
	epsFTPimg.ImageUrl = "~/Images/error.png";
	epsFtpStatusPlaceHolder.Controls.Add(epsFTPimg);
}
else {
	//other code
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900