Grid rendering different after upgrade from 7.2 to 7.5
Hello,
I've upgraded an Umbraco project from 7.2 to 7.5. The Grid in the backoffice works fine after some tweaks, but the rendering in the frontend is different. In one of our grid views we do the following:
var id = random.Next(10, 10000000);
This id is used to give some divs a unique value and also to load some images inside the div. After the upgrade I noticed that some of the divs have the same id. Is there some new caching? I know since 7.3 there is a GridValueConverter: http://issues.umbraco.org/issue/U4-6148#comment=67-21169. Maybe it's related to that.
Also some of the blocks don't render at random. Not sure what could cause that. Anyone seen this before?
I think the views are pretty much the same for rendering the grid, but I can say for sure that something hasn't changed.
One thing that I know has changed: MVC
Perhaps MVC does something differently?
Anyways, how do you initialize random? In a view for each control? The reason that I'm asking is that two different instances of Random will generate the same number (since they're using the same seed if you don't specify one manually).
If you can use the same instance of Random, you will continue to get new random values, instead of the same random value. An alternative could also be to use a GUID or something similar - eg:
Thanks for the reply. I tried to use Guid.NewGuid().ToString().Replace("-", ""), but that doesn't seem to help.
That the MVC part has changed is interesting. We have some surface controllers to render parts of LeBlender. I'll investigate if that has changed.
Here are some screenshots of the live website (Umbraco 7.2):
And here are some screenshots of the local upgraded (Umbraco 7.5) website:
The images are wrong because somehow the ids are still the same (even with GUIDs), but as you can see on the last image some articles are double and at the wrong location. Somehow this happend after the upgrade.
Anders I marked your post as the solution. I replaced (new Random().Next(10, 10000000)) everywhere with Guid.NewGuid().ToString().Replace("-", "") and now everything seems to be working. Some images and blocks are ajax loaded so that's why the screenshots from and live and local could be so different.
It's still really strange that this code worked on Umbraco 7.2 and not on Umbraco 7.5.
Grid rendering different after upgrade from 7.2 to 7.5
Hello,
I've upgraded an Umbraco project from 7.2 to 7.5. The Grid in the backoffice works fine after some tweaks, but the rendering in the frontend is different. In one of our grid views we do the following:
This id is used to give some divs a unique value and also to load some images inside the div. After the upgrade I noticed that some of the divs have the same id. Is there some new caching? I know since 7.3 there is a GridValueConverter: http://issues.umbraco.org/issue/U4-6148#comment=67-21169. Maybe it's related to that.
Also some of the blocks don't render at random. Not sure what could cause that. Anyone seen this before?
Jeroen
Most blocks are a LeBlenderModel. Maybe that also works different.
Jeroen
I think the views are pretty much the same for rendering the grid, but I can say for sure that something hasn't changed.
One thing that I know has changed: MVC
Perhaps MVC does something differently?
Anyways, how do you initialize
random
? In a view for each control? The reason that I'm asking is that two different instances ofRandom
will generate the same number (since they're using the same seed if you don't specify one manually).For instance the following example:
will result in something like (the same result all three times):
If you can use the same instance of
Random
, you will continue to get new random values, instead of the same random value. An alternative could also be to use a GUID or something similar - eg:@{
}will result in something like:
Hi Anders,
Thanks for the reply. I tried to use Guid.NewGuid().ToString().Replace("-", ""), but that doesn't seem to help.
That the MVC part has changed is interesting. We have some surface controllers to render parts of LeBlender. I'll investigate if that has changed.
Here are some screenshots of the live website (Umbraco 7.2):
And here are some screenshots of the local upgraded (Umbraco 7.5) website:
The images are wrong because somehow the ids are still the same (even with GUIDs), but as you can see on the last image some articles are double and at the wrong location. Somehow this happend after the upgrade.
Jeroen
Anders I marked your post as the solution. I replaced (new Random().Next(10, 10000000)) everywhere with Guid.NewGuid().ToString().Replace("-", "") and now everything seems to be working. Some images and blocks are ajax loaded so that's why the screenshots from and live and local could be so different.
It's still really strange that this code worked on Umbraco 7.2 and not on Umbraco 7.5.
Jeroen
Awesome. I forgot about your reply, but didn't really have anything more to add anyways. So good thing that it now works :D
is working on a reply...