Recently I have a simple project on hand, which is much simpler than what I usually write, but it is not smooth. There are many strange problems, such as a strange problem today, here I will talk about the whole process of solution.
The customer requested that a textbox should be unavailable when the second item is selected in dropdownlist. This is a simple problem. Set the autopostback attribute of dropdownlist to "true ", then write the code in the selectedindexchanged event of dropdownlist:
If (ddlframe. selectedindex = 0) // if the first item is selected
{
Txtframeid. Enabled = true;
}
Else
{
Txtframeid. Text = "";
Txtframeid. Enabled = false;
}
If it is normal, this will solve the problem, but today there is a strange problem, no matter how I choose dropdownlist, it selects the first item after refreshing, how can I choose not to select the second item, at first, I thought it was dropdownlist's enableviewstate attribute which was set to false. The result showed that the attribute value was true. This is strange. How can I choose not to select the second item?
So I opened the previously written normal page in notepad to compare the differences between the two pages. I found a suspicious line at the top of the problematic page:
<% @ Page Language = "C #" codebehind = "bookinfo. aspx. cs" autoeventwireup = "false" inherits = "webs. bookinfo" codePage = "936" %>
You must have discovered that, in the end, there is a sentence: codePage = "936", what is this? I checked the information and found the conclusion:
<% @ CodePage = 936%> Simplified Chinese
<% @ CodePage = 950%> traditional Chinese
<% @ CodePage = 65001%> UTF-8
CodePage = "936" indicates Simplified Chinese, so I deleted it and found that dropdownlist can select the second item, but the new problem came out again: CSS seems to have expired, the page becomes messy. so I switched to vs2003. In the page properties, set the character set of the page to gb2312. After saving the settings, I found that the page is normal again. Then, how can I choose the drop-down menu to stop on the first one, I suddenly remembered, Web. the Config File also has a language set, so I will
<Globalization
Requestencoding = "gb2312"
Responseencoding = "gb2312"
/>
Both of them are set to gb2312. After saving, the page is normal and the second item can be selected from the drop-down menu. The problem is solved. Haha! Happy!