Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here my ascx.cs page

I have to set the image url by using this method
like:
C#
protected string GetImgURL(bool IsGoodRepair)
{
   return (IsGoodRepair == true) ? "../../App_Themes/MainTheme/Icon/tick.gif" :"";
}


here i called the above method but showing red code X symbol showing
i want to pass the empty url some time plz hepl me
C#
 protected void btnROfIEvaluation_Click(object sender, EventArgs e)
{
   try
   {
      string actionPerformed = string.Empty;
      this.lblAutoSave.Visible = false;
      this.lblAutoSave.Text = string.Empty;

      int currentYear = Convert.ToInt32(Session["CurrentYear"]) - 1;
      Services objServices = new Services(Convert.ToInt32(Session["CurrentYear"]));
      List<facilityinspectionsdo> objFacilityInspectionsDOList = new List<facilityinspectionsdo>();
      bool ReasonCheck = false;
      string reasons = "Provide comments for ";

      int InspectionID;

      foreach (GridViewRow objGridViewRow in this.GVInspection.Rows)
      {
         InspectionID = Convert.ToInt32(GVInspection.DataKeys[objGridViewRow.RowIndex].Values[0]);

         if (objGridViewRow.RowType == DataControlRowType.DataRow)
         {
            CheckBox chkExemplary = ((CheckBox)objGridViewRow.FindControl("chkExemplary"));
            CheckBox chkIsGood = ((CheckBox)objGridViewRow.FindControl("ChkIsGoodRepair"));
            CheckBox chkIsFair = ((CheckBox)objGridViewRow.FindControl("ChkIsFairRepair"));
            CheckBox chkIsPoor = ((CheckBox)objGridViewRow.FindControl("ChkIsPoorRepair"));
            TextBox txtAction = ((TextBox)objGridViewRow.FindControl("txtAction"));

            //if (InspectionID != 9)
            //{
            //    if ((!chkIsGood.Checked && !chkIsFair.Checked && !chkIsPoor.Checked) && txtAction.Text.Trim().Length == 0)
            //    {
            //        ReasonCheck = true;
            //        reasons += " \\n " + ((Label)objGridViewRow.FindControl("LblInspectionDesc")).Text;
            //    }

            //}
            //else if (InspectionID == 9)
            //{
            //    if (!chkExemplary.Checked && !chkIsGood.Checked && !chkIsFair.Checked && !chkIsPoor.Checked)
            //    {
            //        ReasonCheck = true;
            //        reasons = "Please select Repair Status for \\n " + ((Label)objGridViewRow.FindControl("LblInspectionDesc")).Text;
            //    }
            //}

            FacilityInspectionsDO objFacilityInspectionsDO = new FacilityInspectionsDO();
            objFacilityInspectionsDO.Year = currentYear;
            objFacilityInspectionsDO.CDS = Session["SelectedCDS"].ToString();
            objFacilityInspectionsDO.InspectionID = Convert.ToInt32(GVInspection.DataKeys[objGridViewRow.DataItemIndex].Value);
            objFacilityInspectionsDO.LANGUAGE = this.ddlLanguage.SelectedValue.ToString();

            if (chkIsGood.Checked)
               objFacilityInspectionsDO.IsGoodRepair = 2;
            else if (chkIsFair.Checked)
               objFacilityInspectionsDO.IsGoodRepair = 3;
            else if (chkIsPoor.Checked)
               objFacilityInspectionsDO.IsGoodRepair = 4;

            if (InspectionID == 9)
            {
               if (chkExemplary.Checked)
                  objFacilityInspectionsDO.IsGoodRepair = 1;

                            objFacilityInspectionsDO.Action = string.Empty;
            }
            else
               objFacilityInspectionsDO.Action = txtAction.Text;

            objFacilityInspectionsDOList.Add(objFacilityInspectionsDO);

            ((Label)objGridViewRow.FindControl("lblAction")).Text = txtAction.Text;
            Image imgIsGoodRepair = (Image)objGridViewRow.FindControl("imgIsGoodRepair");
            imgIsGoodRepair.ImageUrl = GetImgURL(chkIsGood.Checked);
         }
      }
      if (ReasonCheck == false)
      {
         actionPerformed = objServices.SaveFacilityInspections(objFacilityInspectionsDOList);
         ((SchoolPlan.NavigationPages.SARCInput)this.Page).InsertApplicationLog(actionPerformed, "Section3_SchoolFacilities_Ver2.ascx/btnROfIEvaluation_Click");
         rebindInspectionGrid();
   }
   //else
   //{
   //    reasons = reasons.Trim();
   //    ScriptManager.RegisterStartupScript(this, this.GetType(), "ReasonMsg", "<script language='javascript'> alert('" + reasons + "'); </script>", false);
   //}
   SaveInspectionDate();
   SetStatus();
   }
   catch (Exception ex)
   {
      LogException(ex);
   }
   //catch (Exception ex)
   //{
   //    //  ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "<script language='javascript'> alert('Error Occured'); </script>", false);
   //    RadAjaxManager rad = (RadAjaxManager)this.Page.Master.FindControl("RadAjaxManager1");
   //    rad.ResponseScripts.Add(string.Format("alert('Error: {0}');", ex.Message.ToString()));
   //}
}
Posted
Updated 13-Dec-12 3:17am
v2

1 solution

Actually, different browsers render HTML in different ways. In your case chrome & firefox are not rendering Tag if image url is not passed or empty. However, IE will render the IMG tag even after image src is not passed.

The Red X mark in IE represent Image not found.

For resolving this problem, you shall Hide your Image control from Code If Image URL is empty. This way the tag would not be rendered in all the browsers.
 
Share this answer
 
Comments
kamal-kondi 13-Dec-12 22:27pm    
i already put the button as visible =false

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