Click here to Skip to main content
11,415,711 members (87,565 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Here my ascx.cs page

I have to set the image url by using this method
like:
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
 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 13-Dec-12 3:47am
Edited 13-Dec-12 4:17am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
kamal-kondi at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,270
1 OriginalGriff 7,512
2 Maciej Los 3,710
3 Abhinav S 3,325
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web04 | 2.8.150427.4 | Last Updated 13 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100