Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Hello,

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:

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');")

rendered: 

 

 <select name="DataGridActividades:_ctl2:dropDownestadoInscricao" id="DataGridActividades__ctl2_dropDownestadoInscricao" name="dropDownestadoInscricao"

class="InputStyle"  

onChange="dropDownItemChange('txtBoxDropDownID','txtBoxDropDownIndex','DataGridActividades__ctl2_dropDownestadoInscricao');"

style="background-color:Transparent;border-width:0px;width:130px;">

 

then on .net v2 the same code renders the following:

 <select name="DataGridActividades$ctl02$dropDownestadoInscricao" id="DataGridActividades_ctl02_dropDownestadoInscricao" name="dropDownestadoInscricao"

class="InputStyle"

onChange="dropDownItemChange('txtBoxDropDownID','txtBoxDropDownIndex','DataGridActividades__ctl2_dropDownestadoInscricao');"

style="background-color:Transparent;border-width:0px;width:130px;">

 

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.

 

Thanks in advance,

Chapas

Posted

Hi,

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.

the solution is:

replace txtBoxDropDownID.ClientID instead of txtBoxDropDownID.ID

I thinks this would be resolved your issue.:)

Thanks & Regards,
Imdad

 
Share this answer
 

Thanks for you answer,

maybe i didn't explained correctly or didn't understand you're explanation. The dropdown id is rendered differently: 

id="DataGridActividades__ctl2_dropDownestadoInscricao"

id="DataGridActividades_ctl02_dropDownestadoInscricao"

 then, when it's called by the onChange event it will not work, the problem is not on the textbox's.

 

Cheers,

Chapas

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900