mardi 15 mars 2016

Server tag not evaluated in server control

On my ASPX page, I need a server control checkbox to pass a backend variable as a parameter in its onclick JS function. But it doesn't seem to work as expected.

Please refer the two checkboxes below:

<input type="checkbox" id="Checkbox1" onclick="ToggleMyOnly('<%=gsListID %>');" />
<input type="checkbox" id="Checkbox2" runat="server" onclick="ToggleMyOnly('<%=gsListID %>');" />

Here the Checkbox1 evaluates the value of gsListID as expected. However, Checkbox2 just passes it as is.

The only difference between these two controls is that Checkbox2 is a server control.

I have searched for a solution for this issue across many sites, but did not get an answer.

I also tried converting the Checkbox1 to an ASP checkbox as follows:

<asp:CheckBox ID="CheckboxASP" runat="server" Text="test" onclick="ToggleMyOnly('<%=gsListID %>');" />

But this also did not evaluate the server tag.

Can anyone help me know how to use the server tag in "onclick" for a server control input element? (Avoiding an ASP:checkbox preferred).




Aucun commentaire:

Enregistrer un commentaire