开发者

Default for ClientIDMode in ASP.NET 4

What is the default for ClientIdMode on

a) Page

b) Control

c) UserCon开发者_开发技巧trol

From 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 is Predictable. The default value of ClientIDMode for a control is Inherit. Because the default for controls is Inherit, the default generation mode 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.)

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜