Show image based on radcombobox index

3 posts, 0 answers
  1. Cristian
    Cristian  avatar
    46 posts
    Member since:
    May 2011

    Posted 16 Mar 2012 Link to this post

    Hi I have a radtooltip with an image inside declared as follows in .aspx file
    <telerik:RadToolTip ID="RadToolTip1" runat="server"
                                                       TargetControlID="help" IsClientID="true" Animation="Slide">
                                                               <asp:Image ID="Image2" runat="server"  />
                                                          
                                                           </telerik:RadToolTip>
    what I want to do is change the image based on the index of a radcombobox.
    I've try something like this

    protected void RadComboBox6_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
           {
              
                   case 1:
                 Image2.ImageUrl = "/App_Themes/img/Mexico-Credencial-del-elector-reverso.jpg";
                       break;

                       
                       break;
                   case 2:
                       Image2.ImageUrl = "/App_Themes/img/AGUILA-PJF.JPG";
                       break;
               }
           }

    But no success. is this the correct way to show an image in a tooltip?
    If yes, how can I change the image on rancombobox.selectedindexchange?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Mar 2012 Link to this post

    Hello Cristian,

    Make sure that you are checking for the selected value in the selectedindexchanged event. Based on the selected value, you can change the image as shown below. Here is the sample code.
    C#:
    protected void combo_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
      RadComboBox combo = (RadComboBox)sender;
      switch (combo.SelectedValue)
      {
       case 1:
       {
         Image2.ImageUrl = "~/Images/img1.gif";
         break;
       }
        case 2:
       {
        Image2.ImageUrl = "~/Images/img2.gif";
        break;
       }
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Cristian
    Cristian  avatar
    46 posts
    Member since:
    May 2011

    Posted 23 Mar 2012 Link to this post

    Hi Princy I solved the problem client side.
    With the following function.
    function SelectedIndexChanged(sender, eventArgs) {
        var item = eventArgs.get_item();
         var value=item.get_value();
          switch (value)
    {
    case "1":
     document.all("Image2").src = "../App_Themes/img/credencial_principal2.jpg";
      break;
    case "2":
    document.all("Image2").src = "../App_Themes/img/pasaportemuestra.jpg";
      break;
      case "3":
     
     document.all("Image2").src = "../App_Themes/img/Cartilla.png";
      break;
    case 0:
      var radToolTip = $find("<%= RadToolTip1.ClientID %>");
    radToolTip.set_text("ELIJA UN TIPO DE IDENTIFICACIÓN");
      break;
    default:
     var radToolTip = $find("<%= RadToolTip1.ClientID %>");
    radToolTip.set_text("ELIJA UN TIPO DE IDENTIFICACIÓN");
    }
           
           
    //      if(item.get_value()=="0"){
    //   var radToolTip = $find("<%= RadToolTip1.ClientID %>");
    //radToolTip.set_text("ELIJA UN TIPO DE IDENTIFICACIÓN");
     
    //}
    //       
    //     if(item.get_value()=="1"){
    //   document.all("Image2").src = "../App_Themes/img/credencial_principal2.jpg";
    //  
     
    //    }
    //      if(item.get_value()=="2"){
    //   document.all("Image2").src = "../App_Themes/img/pasaportemuestra.jpg";
    //  
     
    //    }
    //       if(item.get_value()=="3"){
    //   document.all("Image2").src = "../App_Themes/img/Cartilla.png";
    //  
     
    //    }
        
    }

    For some reason it didn't worked until I do it client side.
    Thanks anyway.
Back to Top