Reputation: 21
I have js script block (very long one that does editing capabilities to an invoice page).
I want to enable/disable this functionality on the server-side. First thing popped up on my mind was to say runat="server" to the tag, and set visible=true/false to asp.net, thinking asp.net does not render the HTML for non-visible items, so the block wouldn't load at all, which was what I wanted. But I quickly realized that saying runat="server" to client-side code was a real bad idea :)
What ar emy options, besides loading script from client side. Cuz I have other buttons that come from the server-that will enable dieable too ... If I use js for them the code will be ugly ... Thanks in advance
Upvotes: 2
Views: 2640
Reputation: 66641
Try this trick
<asp:Literal run="server" id="MyScriptBlock" EnableViewState="false">
here type what ever you like
</asp:Literal>
and just make Visible or not the MyScriptBlock
Upvotes: 1