How do I remove Javascript references from Custom Server Control?http://forums.asp.net/t/1770412.aspx/1?How+do+I+remove+Javascript+references+from+Custom+Server+Control+Wed, 22 Feb 2012 00:01:35 -050017704124836137http://forums.asp.net/p/1770412/4836137.aspx/1?How+do+I+remove+Javascript+references+from+Custom+Server+Control+How do I remove Javascript references from Custom Server Control? <p>We are overriding the default menu control's Render method to create a simple, fast, small footprint static css menu which is working fine.&nbsp; However the javascript (and css) files that goes with the default control is loaded by scriptresource.axd references. Is there a way to remove these scripts so they are never sent to the client?&nbsp; </p> <p></p> <pre class="prettyprint">Public Class Menu : Inherits System.Web.UI.WebControls.Menu</pre> 2012-02-16T14:55:39-05:004836216http://forums.asp.net/p/1770412/4836216.aspx/1?Re+How+do+I+remove+Javascript+references+from+Custom+Server+Control+Re: How do I remove Javascript references from Custom Server Control? <p>The WebControls Menu uses an internal renderer, so you can't even override the OnPreRender method and then remove the registered scripts. I don't think there's anything that you can do, I'm afraid.</p> 2012-02-16T15:49:52-05:004837816http://forums.asp.net/p/1770412/4837816.aspx/1?Re+How+do+I+remove+Javascript+references+from+Custom+Server+Control+Re: How do I remove Javascript references from Custom Server Control? <p>Is there not a way, through reflection, to completely dissasemble the control allowing one to copy into a new object (and further edit that portion)?</p> 2012-02-17T14:59:30-05:004838461http://forums.asp.net/p/1770412/4838461.aspx/1?Re+How+do+I+remove+Javascript+references+from+Custom+Server+Control+Re: How do I remove Javascript references from Custom Server Control? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>stevenbey</h4> <p></p> <p>The WebControls Menu uses an internal renderer, so you can't even override the OnPreRender method and then remove the registered scripts. I don't think there's anything that you can do, I'm afraid.</p> <p></p> </blockquote> <p></p> <p>Hello</p> <p>I think maybe we can override the OnPreRender by ignoring the base.OnPreRender(e) and write your own logicIf I take you wronglykindly correct me</p> <pre>&nbsp;<span>public</span>&nbsp;<span>class</span>&nbsp;<span>MyMenu</span>&nbsp;:&nbsp;System.Web.UI.WebControls.<span>Menu</span> &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>public</span>&nbsp;<span>override</span>&nbsp;<span>void</span>&nbsp;OnPreRender(<span>EventArgs</span>&nbsp;e) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Do not use thisbut only to use your own method<span>base</span>.OnPreRender(e); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;}</pre> <p>If this still failsI'm afraid you cannot override itWellyou have to inherit from WebControl and do writing manually</p> 2012-02-18T05:13:54-05:004839143http://forums.asp.net/p/1770412/4839143.aspx/1?Re+How+do+I+remove+Javascript+references+from+Custom+Server+Control+Re: How do I remove Javascript references from Custom Server Control? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Decker Dong - MSFT</h4> If I take you wronglykindly correct me</blockquote> <p></p> <p>No, you are correct.&nbsp; I was so focussed on trying to remove the references that had been added (as per the title of the thread) that I didn't see the obvious solution -&nbsp; don't allow the script to be added in the first place!</p> 2012-02-19T00:05:58-05:004839155http://forums.asp.net/p/1770412/4839155.aspx/1?Re+How+do+I+remove+Javascript+references+from+Custom+Server+Control+Re: How do I remove Javascript references from Custom Server Control? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>stevenbey</h4> <p></p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Decker Dong - MSFT</h4> If I take you wronglykindly correct me</blockquote> <p></p> <p>No, you are correct.&nbsp; I was so focussed on trying to remove the references that had been added (as per the title of the thread) that I didn't see the obvious solution -&nbsp; don't allow the script to be added in the first place!</p> <p></p> </blockquote> <p></p> <p>Never mindHaha ^_^Hope the OP can solve his problemBut still hope you can be online and chat with us</p> 2012-02-19T00:23:46-05:004843327http://forums.asp.net/p/1770412/4843327.aspx/1?Re+How+do+I+remove+Javascript+references+from+Custom+Server+Control+Re: How do I remove Javascript references from Custom Server Control? <p>It worked!!!</p> <p>Thanks guys!</p> 2012-02-21T14:26:59-05:004843953http://forums.asp.net/p/1770412/4843953.aspx/1?Re+How+do+I+remove+Javascript+references+from+Custom+Server+Control+Re: How do I remove Javascript references from Custom Server Control? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>kcornwell</h4> <p></p> <p>It worked!!!</p> <p>Thanks guys!</p> <p></p> </blockquote> <p></p> <p>Glad to hear thathope you can come here more to help others or chat with us about your ASP.NET technology</p> <p>Reguards</p> 2012-02-22T00:01:35-05:00