I have a masterpage that contains all the javascript and inside the content control, there is a link that calls a javascript function and I want to pass the id once it’s rendered differently by the server.
<asp:TextBox ID="txtstart" runat="server" Width="20%"></asp:TextBox>
<a title="Pick Date from Calendar" onclick="calendarPicker('<% txtstart.ClientId %>');" href="javascript:void(0);" rel="nofollow noreferrer noopener" rel="nofollow noreferrer noopener">
However, I keep getting this error:
Property access must assign to the property or use its value.
How would I be able to accomplish this?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Try this instead (notice the <%= in the onclick attribute):
<asp:TextBox ID="txtstart" runat="server" Width="20%" />
<a title="Pick Date from Calendar"
onclick="calendarPicker('<%= txtstart.ClientId %>');"
href="javascript:void(0);" rel="nofollow noreferrer noopener" rel="nofollow noreferrer noopener">
</a>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0