views:

19

answers:

1

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

+1  A: 

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

Aristos
literal renders to <span> .. do you mean wrapping script block with some other tag right .. I was thinking the same .. thanks a lot
Emre
@Emre literal not render to span ! They are empty, that why they called literal. try it, I have try it and its working.
Aristos
yes it is .. but i used a placeholder instead... but thanks for the info .. thanks a lot :)
Emre