Click here to Skip to main content
15,887,928 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hiiiiiiiiiii


C#
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
      {
          if (Button1.Text == "ON")
          {
              Image.ImageUrl = "C:\\Avail.Prg";
              Button1.Text = "OFF";
          }
          else
          {
              Image4.ImageUrl = "C:\\Not avail>Prog";
              Button1.Text = "ON";
          }
Posted
Updated 12-Feb-14 20:05pm
v2
Comments
JoCodes 13-Feb-14 2:15am    
Whats the error?
harshavardhan12345678 13-Feb-14 2:17am    
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (Button1.Text == "ON")
{
Image.ImageUrl = "C:\\Avail.Prg";
Button1.Text = "OFF";
}
else
{
Image4.ImageUrl = "C:\\Not avail>Prog";
Button1.Text = "ON";
}
JoCodes 13-Feb-14 2:18am    
Not that , The Error message you are getting.
harshavardhan12345678 14-Feb-14 1:18am    
Error 2 An object reference is required for the non-static field, method, or property 'System.Web.UI.WebControls.Image.ImageUrl.get' C:\Users\bhagya\Documents\Visual Studio 2010\WebSites\image\Default.aspx.cs 23 13 C:\...\image\
JoCodes 14-Feb-14 1:22am    
Have you tried the solution i have posted?

1 solution

Image is a Control Type .

So you cant assign to it like

C#
Image.ImageUrl = "C:\\Avail.Prg";


Create a Image control with the ID and do like below

Something like

<asp:ImageMap ID="ImageMap1" runat="server"></asp:ImageMap>//Markup


And in Code Behind

Image1.ImageUrl = "C:\\Avail.Prg";// Image1 stands for ID
 
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