Click here to Skip to main content
Sign Up to vote bad
good
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 - 2:47
Edited 13 Dec '12 - 3:17


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.
  Permalink  
Comments
kamal-kondi - 13 Dec '12 - 22:27
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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 424
1 Mahesh Bailwal 398
2 Maciej Los 205
3 Aarti Meswania 173
4 Rohan Leuva 165
0 Sergey Alexandrovich Kryukov 9,417
1 OriginalGriff 7,204
2 CPallini 3,933
3 Rohan Leuva 3,211
4 Maciej Los 2,743


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 13 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid