ASP.NET - Want To Disable The html Image Control Disabled through code behind asp.net C#

Asked By Justin Deva on 16-Jun-12 06:37 AM


    

Want To Disable The html Image Control Disabled through code behind asp.net C# with respect to such Conditions...help pls..

Vikram Singh Saini replied to Justin Deva on 16-Jun-12 07:10 AM
Declare image control as:

<img id="imageControl" runat="server" src="" />

and in code-behind file code as:

imageControl.Disabled = true;
Lalit M replied to Justin Deva on 16-Jun-12 01:31 PM
Add the runat=”server” to this html control and then set the visible property in the code behind.show example

 protected void Button1_Click(object sender, EventArgs e)
    {
      //Condition
      if (true)
      {
        //Hide the img control
        Page.RegisterStartupScript("imgDisplay", "<script> document.getElementById('imgClient').style.visibility='hidden'; </script> ");
      }
      else
      {
        //Display the img control
        Page.RegisterStartupScript("imgDisplay", "<script> document.getElementById('imgClient').style.visibility='display'; </script>");
      }
    }

or you can  use client script to hide or display this html control. To do this, register the script in the code behind base on the condition.