问题描述
您好,
我在一个网页上有一个奇怪的行为,我想了解它,何时,何地以及如何更正此问题.在.net v1.1.4上,该代码可以完美地工作:
i''m having a strange behavior on a webpage that i want to understand, when, where and how to correct this. On .net v1.1.4 this code worked flawlessly:
在数据网格事件"itemdatabound"的代码后面:
on code-behind on the datagrid event ''itemdatabound'':
ddlist.Attributes.Add("onChange","dropDownItemChange("& txtBoxDropDownID.ID&'',"& txtBoxDropDownIndex.ID&"'',''DataGridActividades__ctl&(e.Item.ItemIndex + 2).ToString()& ;"_dropDownestadoInscricao");)
ddlist.Attributes.Add("onChange", "dropDownItemChange(''" & txtBoxDropDownID.ID & "'',''" & txtBoxDropDownIndex.ID & "'',''DataGridActividades__ctl" & (e.Item.ItemIndex + 2).ToString() & "_dropDownestadoInscricao'');")
渲染的:
< select name ="DataGridActividades:_ctl2:dropDownestadoInscricao" id ="DataGridActividades __ ctl 2 _dropDownestadoInscricao"name ="dropDownestadoInscricao"
<selectname="DataGridActividades:_ctl2:dropDownestadoInscricao"id="DataGridActividades__ctl2_dropDownestadoInscricao"name="dropDownestadoInscricao"
class ="InputStyle"
class="InputStyle"
onChange ="dropDownItemChange(''txtBoxDropDownID'',''txtBoxDropDownIndex'',''DataGridActividades __ ctl 2 _dropDownestadoInscricao''); "
onChange="dropDownItemChange(''txtBoxDropDownID'',''txtBoxDropDownIndex'',''DataGridActividades__ctl2_dropDownestadoInscricao'');"
style ="background-color:Transparent; border-width:0px; width:130px;">
然后在.net v2上,相同的代码将呈现以下内容:
then on .net v2 the same code renders the following:
<selectname="DataGridActividades$ctl02$dropDownestadoInscricao"id="DataGridActividades_ctl02_dropDownestadoInscricao"name="dropDownestadoInscricao"
class ="InputStyle"
class="InputStyle"
onChange ="dropDownItemChange(" txtBoxDropDownID," txtBoxDropDownIndex," DataGridActividades__ctl2_dropDownestadoInscricao);"
onChange="dropDownItemChange(''txtBoxDropDownID'',''txtBoxDropDownIndex'',''DataGridActividades__ctl2_dropDownestadoInscricao'');"
style ="background-color:Transparent; border-width:0px; width:130px;">
因此,它呈现的ID与我指定的ID不同,并且在呈现的页面上,它使用的是JavaScript,它将从它的ID.这就是为什么它不起作用.
So this renders a different ID than the one that i specified and on the rendered page it''s using a javascript that will get that control from it''s ID. That''s why it''s not working.
预先感谢,
Chapas
推荐答案
class ="InputStyle"
class="InputStyle"
onChange ="dropDownItemChange(" txtBoxDropDownID," txtBoxDropDownIndex," DataGridActividades__ctl2_dropDownestadoInscricao);"
onChange="dropDownItemChange(''txtBoxDropDownID'',''txtBoxDropDownIndex'',''DataGridActividades__ctl2_dropDownestadoInscricao'');"
style ="background-color:Transparent; border-width:0px; width:130px;">
因此,它呈现的ID与我指定的ID不同,并且在呈现的页面上,它使用的是JavaScript,它将从它的ID.这就是为什么它不起作用.
So this renders a different ID than the one that i specified and on the rendered page it''s using a javascript that will get that control from it''s ID. That''s why it''s not working.
预先感谢,
Chapas
当您的代码完全以HTML呈现时,它将自动重命名服务器控件,因此您的控件可能位于更新面板中.
When your code is completely renders in HTML it will automatically renamed a server control, so might be possible you control is inside the update panel.
解决方案是:
替换 txtBoxDropDownID.ClientID 而不是
我认为这可以解决您的问题.:)
I thinks this would be resolved your issue.:)
谢谢问候,
圣训
Thanks & Regards,
Imdad
这篇关于.net v2输出与指定ID不同的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!