Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Akeem 43 posts 198 karma points
    May 25, 2016 @ 22:05
    Akeem
    0

    Umbraco : Input string was not in a correct format.

    Hi ,

    Please help me . each time i run my application, am getting this error . Looking at the code , all is fine . I don'enter image description heret have any error on my code . Please help me .

  • Manish 373 posts 932 karma points
    May 26, 2016 @ 05:50
    Manish
    0

    Before assigning it to src

    Check like this

    if(imgRolloverOff != null)
    {
    your image tag 
    }
    

    Manish

  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    May 26, 2016 @ 06:30
    Dennis Adolfi
    0

    Hi Akeem.

    The errormessage "Input string was not in a correct format" usally apears when a parse is made from a string to a int. Im guessing that a parse is beeing made in the Umbraco.TypedMedia() function and its causing an error. Probobly because the @CurrentPage.carouselImg3 is null or Empty. You sholud probobly make sure that CurrentPage has a value for carouselImg3 and also that it is of type int.

    Try the following:

    @if (CurrentPage.HasValue("carouselImg3"))
    {
        int mediaId;
        Int32.TryParse(CurrentPage.carouselImg3.ToString(), out mediaId);
    
        if (mediaId != 0)
        {
            IPublishedContent imgRolloverOf = Umbraco.TypedMedia(CurrentPage.carouselImg3.ToString());
            if (imgRolloverOf != null)
            {
                <img class="img-responsive center-block" src="@imgRolloverOf.Url"/>
            }
        }
    }
    

    Hope this works out for you!!

    PS.

    Just to double-check, CurrentPage.carouselImg3 is of datatype mediapicker?

  • Akeem 43 posts 198 karma points
    May 26, 2016 @ 13:15
    Akeem
    0

    Hi Dennis,

    CurrentPage.carouselImg3 is of datatype mediapicker . However , am still getting the same error .

    enter image description here

    Please help me . I dont know how to solve this issue . My code now :

     <div class="item">
    
    
                            @if (CurrentPage.HasValue("carouselImg3"))
                            {
                                int mediaId;
                                Int32.TryParse(CurrentPage.carouselImg3.ToString(), out mediaId);
    
                                if (mediaId != 0)
                                {
                                    IPublishedContent imgRolloverOf = Umbraco.TypedMedia(CurrentPage.carouselImg3.ToString());
                                    if (imgRolloverOf != null)
                                    {
                                        <img class="img-responsive center-block" src="@imgRolloverOf.Url" />
                                    }
                                }
                                <a class="carousel-caption" href="@Umbraco.NiceUrl(@Convert.ToInt32(@Umbraco.Field("carousel3Link").ToString()))"></a>
                            }
                        </div>
    
  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    May 26, 2016 @ 13:25
    Dennis Adolfi
    101

    Could it be this line that breaks for you?

     <a class="carousel-caption" href="@Umbraco.NiceUrl(@Convert.ToInt32(@Umbraco.Field("carousel3Link").ToString()))"></a>
    

    Have you tried uncommenting the above line?

    What datatype is carousel3Link? It looks like it could be a contentpicker, is that correct? In that case, could you try:

     <div class="item">
                                @if (CurrentPage.HasValue("carouselImg3"))
                                {
                                    int mediaId;
                                    Int32.TryParse(CurrentPage.carouselImg3.ToString(), out mediaId);
    
                                    if (mediaId != 0)
                                    {
                                        IPublishedContent imgRolloverOf = Umbraco.TypedMedia(CurrentPage.carouselImg3.ToString());
                                        if (imgRolloverOf != null)
                                        {
                                            <img class="img-responsive center-block" src="@imgRolloverOf.Url" />
                                        }
                                    }
                                }
    
                                @if (CurrentPage.HasValue("carousel3Link"))
                                {
                                    int nodeId;
                                    Int32.TryParse(CurrentPage.carousel3Link.ToString(), out nodeId);
    
                                    if (nodeId != 0)
                                    {
                                        IPublishedContent node = Umbraco.TypedContent(CurrentPage.carousel3Link.ToString());
                                        if (node != null)
                                        {
                                            <a class="carousel-caption" href="@node.Url"></a>
                                        }
                                    }
                                }
    
        </div>
    
  • Akeem 43 posts 198 karma points
    May 26, 2016 @ 14:23
    Akeem
    1

    HI Dennis,

    You are a genius . I was just wondering how you knew that was a contentPicker . Its it works on my development . Now i have to transfer the code to the real site .

    Also i just noticed what happened . The content picker is empty . That might be reason its throwing the exception . Am working with the website designer , so am not able to pinpoint what has changed some times in the umbraco admin section ...

    However , as part of fixing this issue , i upgraded umbraco for my development site . but it doesnt still work yesterday . Can i still use courier from umbraco 7.4 new version with umbraco previous version . The sites were the same version before when i was using the courier .

  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    May 27, 2016 @ 06:25
    Dennis Adolfi
    0

    Thank you Akeem! :)

    I dont know, made sense that it would be a contentpicker. Yes, if the contentpicker if empty i could see why it threw the exception.

    About your last question about Courier, you sholud post it as a separate forum thread, since Im not very fimiliar with courier.

    Best of luck to you!!!

    Have a great day!!

  • Akeem 43 posts 198 karma points
    May 27, 2016 @ 13:11
    Akeem
    1

    Thank You Dennis ..

Please Sign in or register to post replies

Write your reply to:

Draft