Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling ClientID from aspx

"")" />

that doesn't work, the error says: Parser Error Message: Server tags cannot contain <% ... %> constructs.

Any aproaches to solve this ? Thank you ;)

like image 947
euther Avatar asked Dec 17 '22 02:12

euther


1 Answers

You're calling a JS event (onchange), not a server event, so just pass in this.id.

<input type="checkbox" id="chbSaveState" runat="server" tabindex="3"  
onchange="SaveState(this.id)" /> 

To be clear, this.id and <%=chbSaveState.ClientID%> will return the same value in this case. Since you're calling this on an event of chbSaveState, you can just use the easily accessible JS property here, rather than <%=chbSaveState.ClientID%>, which requires the server to return the id which is generated by the server for that control.

like image 56
jball Avatar answered Jan 04 '23 02:01

jball