Can't Add Widget

Topics: ASP.NET 2.0, Business Logic Layer, Controls
Jul 24, 2011 at 12:08 PM

I have several widget zones on a page. Some are in the master page and others are scattered on pages throughout the site. When I select a widget type and click the 'Add' button, nothing happens, and I'm redirected to a 404. It seems the javascript function which is executing isn't returning false so the button click isn't being cancelled. If I manually execute the code in the firebug console, it works as expected. The code in /App_Code/Controls/WidgetZone.cs is that from BE.NET 2.5. I've tried modifying it at line 206 with no effect. The code I have is:


                "<input type=\"button\" value=\"Add\" onclick=\"BlogEngine.widgetAdmin.addWidget(BlogEngine.$('{0}').value, '{1}')\" />", 
            writer.Write("<div class=\"clear\" id=\"clear\">&nbsp;</div>");


                "<input type=\"button\" value=\"Add\" onclick=\"BlogEngine.widgetAdmin.addWidget(BlogEngine.$('{0}').value, '{1}'); return false;\" />", 
            writer.Write("<div class=\"clear\" id=\"clear\">&nbsp;</div>");// fails

                "<input type=\"button\" value=\"Add\" onclick=\"return BlogEngine.widgetAdmin.addWidget(BlogEngine.$('{0}').value, '{1}')\" />", 
            writer.Write("<div class=\"clear\" id=\"clear\">&nbsp;</div>"); // also fails

It works as much as I need it to, but it would be nice to be able to use the buttons rather than manually executing the JavaScript:

BlogEngine.widgetAdmin.addWidget(BlogEngine.$('widgetselector_Overall-Footer-contact').value, 'Overall-Footer-Contact')

Jul 24, 2011 at 1:40 PM

The reason this seems to be happening is that blog.js (and the rest of the default scripts) aren't included on any page but default.aspx. Is there a way around this to make widgets work anywhere?

Jul 27, 2011 at 10:10 AM

You mean when you are viewing an individual post page, or even on contact.aspx or archive.aspx, blog.js is not there?

Is blog.js in the HTML and just not loading correctly .... or is blog.js not in the HTML at all?

And just in case you weren't aware, the blog.js script tag typically looks like:

<script type="text/javascript" src="/js.axd?path=%2fScripts%2fblog.js&amp;minify="></script>

Jul 27, 2011 at 10:31 AM

Yes, only default.aspx has the blog.js and widget.js files included. I know I could manually add a reference, but I thought these were supposed to be added by BE.NET.

Jul 29, 2011 at 9:30 AM

Unless I'm mistaken, but I have other sites where I can use widget functionality on other pages.