Default for ClientIDMode in ASP.NET 4
What is the default for ClientIdMode on
a) Page
b) Control c) UserCon开发者_开发技巧trolFrom what I have read it is Predictable, Inherit, Inherit. I expected the default on the Page to be AutoId. Wouldn't Predictable break things?
MSDN says:
The default value of
ClientIDMode
for a page isPredictable
. The default value ofClientIDMode
for a control isInherit
. Because the default for controls isInherit
, the default generation mode isPredictable
. (However, if you use Visual Studio to convert a Web project to ASP.NET 4 from an earlier version, Visual Studio automatically sets the site default toAutoID
in theWeb.config
file.)
But also should mention that some old pages on MSDN still says that default value of ClientIDMode
for a page is AutoID
(e.g. here) as was stated in my previous answer.
"The default value of ClientIDMode for a page is Predictable."
"However, if you use Visual Studio to convert a Web project to ASP.NET 4 from an earlier version, Visual Studio automatically sets the site default to AutoID in the Web.config file."
http://msdn.microsoft.com/en-us/library/system.web.ui.clientidmode.aspx
If you set it on the control, use the value of the control
else if you set it on the page, use the value of the page
else if you entered it in the web.config, use the value in the web.config
else use Predictable.
Any of these can and will break code if the programmer assumed it to be doing something different from what it really is doing.
精彩评论