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't have any error on my code . Please help me .
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?
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 .
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't have any error on my code . Please help me .
Before assigning it to src
Check like this
Manish
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:
Hope this works out for you!!
PS.
Just to double-check, CurrentPage.carouselImg3 is of datatype mediapicker?
Hi Dennis,
CurrentPage.carouselImg3 is of datatype mediapicker . However , am still getting the same error .
Please help me . I dont know how to solve this issue . My code now :
Could it be this line that breaks for you?
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:
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 .
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!!
Thank You Dennis ..
is working on a reply...