Last post Aug 30, 2018 03:33 AM by Saavik
Aug 22, 2018 04:22 AM|Saavik|LINK
I have a website with a DropDownList which lets a user change Themes (Dark, Light)
The two values (Dark, Light) are in the .aspx as ListItems for the DropDownList. When the page loads, code-behind gets a default from web.config and sets the DropDownList.SelectedIndex to that
value. When the user chooses a theme, the choice is captured from the DropDownList and placed in a Session variable to remember, until user changes the theme again (or not).
This works with all browsers except Microsoft Edge, and only in production - I cannot recreate the problem in development. At page load, when the default is set in code-behind (let's say Light) and Session variable is set to
Light and the page is reloaded, the DropDownList shows the SelectedValue to be the first in the list, regardless of user choice.
Since this is happening in production, please go to www.PhotographyByOri.com to see this in action. The default (in code-behind) is set to Light, but Microsoft Edge says in DropDownList.SelectedIndexChanged, that the selected
value is always the first in the list.
I am at a loss - help is most appreciated!
Aug 22, 2018 05:19 AM|KathyW|LINK
I can't reproduce your issue, once the dropdown is actually selected. It takes a long time to be able to select it because your page is shown as still loading for quite some time. Once the images are in browser cache that issue goes away for subsequent
visits to the page.
Aug 24, 2018 03:03 AM|Saavik|LINK
Thank you for trying to reproduce the issue. Depending on when you tried, I may have been working on the issue, which could account for the long delay. The site is generally fairly quick.
I have left it alone at this moment, and the issue still persists.
I tried logging various points in the code by writing out to a log text file. It looks like the first time the code tries to set the DropDownList to a default value by executing this line
DropDownList.SelectedIndex = [0 or 1]
.NET reacts as if the DropDownList was set by user and restarts loading the page using the first value in the DropDownList.
Is there a better way to set the DropDownList to a value in code-behind?
Help is most appreciated.
Aug 25, 2018 08:35 PM|KathyW|LINK
Since I can't reproduce your issue, there is no way I can help you. Your code works fine for me on two different computers, in Edge. (And yes, it's now fast.)
Have you tried asking others you know to test it? If it's only you who sees the problem, it's not a problem for your site, but a mystery for yourself.
Aug 30, 2018 03:33 AM|Saavik|LINK
Thank you again, KathyW for your time and trying to help.
I finally figured it out. While it may seem silly on one hand, it is this kind of unexpected behavior that can cost time (and money).
It was a third party software that was only installed on my test machine and test tablet. Once uninstalled, all was good.
Again, thank you for your time.