本地和Live Server上的ID更改

时间:2013-12-26 08:52:20

标签: c# asp.net

我在本地代码的隐藏字段中有以下ID

<input type="hidden" name="ctl00$MainContent$HiddenFieldForPrimaryUserId" id="**MainContent_HiddenFieldForPrimaryUserId**" value="0">

当我在Live Test Server上传相同的代码时,它的ID将更改为以下

<input type="hidden" name="ctl00$MainContent$HiddenFieldForPrimaryUserId" id="**ctl00_MainContent_HiddenFieldForPrimaryUserId**" value="0">

请告诉我这背后的原因并解决这个问题 在此先感谢。

1 个答案:

答案 0 :(得分:0)

web.config clientIDMode设置更改为静态:例如

<pages enableEventValidation="false" clientIDMode="Static">

还要确保测试服务器上的应用程序池在.NET 4.0下运行,因为clientIDMode web.config设置仅在.NET 4及更高版本中可用。