This project is read-only.

Search button does not work

Topics: Controls, Themes
Jun 4, 2009 at 7:46 AM
Edited Jun 4, 2009 at 7:51 AM

I upgraded from version 1.4.5 to 1.5 and it broke the theme I was using, so I started over and picked a theme (Stardust)  that worked the way I wanted but had colors I did not care for. I got a version to work well enough, but not quite the way I wanted so ended up digging in a bit more than planned. The fairly generic version running under is at Note the search bar up in the header area.

        <div id="searchform">
            <button style="float:right;z-index:1;" type="submit" onkeypress="Search('<%=Utils.RelativeWebRoot%>');" onclick="Search('<%=Utils.RelativeWebRoot%>');" value="Search"/>
            <img alt="search" src="~/themes/stardust/images/cerca.jpg" id="imgBtn" runat="server"/>
            <blog:SearchBox ID="searchBox" runat="server"></blog:SearchBox>

Replaced by the following:

 <div id="searchform">
    <button  type="submit" onkeypress="Search('<%=Utils.RelativeWebRoot%>');" onclick="Search('<%=Utils.RelativeWebRoot%>');" value="Search"></button>
   <blog:SearchBox ID="searchBox" runat="server" ></blog:SearchBox>

#searchform button
 position: absolute;
 top: 0px;
 background: transparent url(images/cerca.jpg) no-repeat;
 border: 1;
 padding: 0;
 margin:0 0 0 -25px;
 color: #fff;
#searchform #searchbutton
 font-family:Comic Sans MS;

Result In the address bar: http://localhost:52031/BlogEngine.NET/default.aspx? and no search on click. However, search by keypress works fine.

Clearly there must be something wrong with my syntax. How should it be written?

I am running version for development, but a couple of pages did not work: blogroll and profile I think they were.



Jun 4, 2009 at 8:49 AM

The name of the JS search function was changed in 1.5.  Instead of Search(...), it should now be and please note the "s" in search is lower-case.  I count 4 instances of Search(...) in your code above.  All of them should be changed to

Jun 5, 2009 at 10:51 PM

Thanks Ben,

That made the eventual solution possible. In addition, it was necessary to change the button from :

<button  type="submit"


<button  type="button"

And now it works.

Jun 9, 2009 at 5:47 AM

Hi Kal,

Did your solution worked by just changing type="submit" to type="button"?


Aug 18, 2009 at 6:20 PM

Hi All,

I'm having a problem with the Search Button / Search Engine feature in BlogEngine .NET. An error is raised on the search, and results are not returned as a result.

Some background:

  • I downloaded and worked with BlogEngine .NET in Visual Web Developer Express 2008 a few months ago
  • I recently mistakenly upgraded the project in VWD from an ASP .NET 2.0 project to an ASP .NET 3.5 project from a dialog on start-up
  • Search functionality works fine after the upgrade from ASP .NET 2.0 to ASP .NET 3.5 on my local machines (successful on both Windows XP and 64-bit Windows Vista before the upgrade)
  • Deployed project to live host provider
  • Search fails on live host provider
  • Asked Admininstrator Tech to share App_Data folder -- search still fails

A 404 or 500 error is not raised, but an error is raised in the status bar. It reads:


Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; InfoPath.2; .NET CLR 3.0.30729)
Timestamp: Tue, 18 Aug 2009 17:27:25 UTC
Message: 'BlogEngine' is undefined
Line: 63
Char: 1
Code: 0
Message: 'BlogEngine' is undefined
Line: 63
Char: 1
Code: 0
Message: 'BlogEngine' is undefined
Line: 63
Char: 1
Code: 0
Message: 'BlogEngine' is undefined
Line: 63
Char: 1
Code: 0
Message: 'BlogEngine' is undefined
Line: 63
Char: 1
Code: 0


IE chokes on the BlogEngine object in this bit of code:


<div id="header">
<div id="sbstyle"><div id="searchbox">
<label for="searchfield" style="display:none">Search</label><input type="text" value="search zeeland blog" id="searchfield" onkeypress="if(event.keyCode==13) return'/')" onfocus="BlogEngine.searchClear('search zeeland blog')" onblur="BlogEngine.searchClear('search zeeland blog')" /><input type="button" value="Search" id="searchbutton" onclick="'/');" onkeypress="'/');" /></div>
What am I missing? The project performs searches fine on my local machine, but not on the live site.
The BlogEngine .NET control panel works, and I can post updates to the site. I simply cannot search the blog content.
Thanks in advance.



Sep 1, 2009 at 10:43 PM

Just following up:

Any explanation to help sort through this?

Sep 3, 2009 at 9:40 AM

I would make sure the blog.js file in your root folder is the correct version.  If you open up the blog.js file, the first two lines should read:

// global object
BlogEngine = {

Can you pull up your RSS feed, btw?  Everything else is running fine?

Sep 3, 2009 at 4:29 PM

WE got it working here a couple of days after the original post. As I recall, changing the button type did help, but did not solve the problem.  I believe the other problem was actually unrelated to the button, or at least not directly.

Sep 3, 2009 at 8:06 PM
BenAmada wrote:

I would make sure the blog.js file in your root folder is the correct version.  If you open up the blog.js file, the first two lines should read:

// global object
BlogEngine = {

Can you pull up your RSS feed, btw?  Everything else is running fine?

Hi Ben,

Yes, the first two lines of blog.js match what you mentioned. I verified both locally and the live version.

And, yes, the RSS feed works great. The admin control panel also works great.

Thanks for the feedback on this. Still in the dark about why the search + search button does not perform live, when this works great locally.


Sep 3, 2009 at 8:08 PM

@Kal : thanks, perhaps I appended this thread with an issue distinct from the original thread message. I did investigate the <button /> tag comparison to see if it affected the search issue I'm having but it did not.

Thanks for the response, though.


Sep 3, 2009 at 11:16 PM

Although unlikely, I would also check the file size of blog.js on your production machine versus local machine.  Make sure it's the same number of bytes.

Can you post a comment on your blog, btw?  Comments also rely on the blog.js file.

Sep 4, 2009 at 1:03 AM

Hi Ben,

Interesting . . . I have experimented with this on the site (local and live).

In my test on the local version, I selected a post, enabled comments, completed the comments form and posted successfully.

This same steps performed on the live site did not work. The form did not submit, and the form process idled.

I also checked the file size for blog.js - the local and live versions are both 18 KB.




Sep 4, 2009 at 2:30 AM

The blog.js file is delivered to the browser via BE's JavaScript handler (js.axd).  The URL to that is normally going to be something like:

When you pull your site up, if you do a View Source, and search for blog.js, you'll find a <script> tag that looks something like:

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

By looking at the "src", you can see what the URL is to the JS.axd file.

I would try navigating directly to the JS.axd file (with the path=... in the URL) to see if the JS file comes up for you.  The JS.axd handler compresses the blog.js file and removes comments.  If you navigate directly to the URL, it should start off looking like:

BlogEngine ={$: function(id){return

The two possible problems I can think of would be a 404 error for the JS.axd file.  But if your RSS feed works, then that is probably not the case.  I've also seen a case when the blog.js file was being mis-encoded by the JS.axd handler and some garbarge characters were being mixed in with the normal JavaScript.

A 3rd possible cause I've seen for this was for people in a Mosso type load balancing environment.  I believe there was a very simple solution where all the person had to do was remove the first line in blog.js.  The first line is a JS comment, which we discussed a few messages above.

// global object

The person removed that comment, and his problem was resolved.

Sep 9, 2009 at 10:48 PM

Hi Ben,

Ah, I seem to be missing a key component here; I do not have the js.axd file in my project.

How can I get correct this, and get the right version of the js.axd file to run with the site?

My RSS feed works fine.

Also, I tried removing the comment ("//global object") from the blog.js, but I think this issue is centering on the missing js.axd file.

Thank you for your assistance with this.


Sep 9, 2009 at 11:45 PM

js.axd isn't a physical file in your project.  It's injected into the page at runtime.  It should show up when you do a View Source.  In your browser, if you do a View Source and search for "js.axd", does it show up?  You can also try searching for blog.js in the HTML source.

Sep 10, 2009 at 5:37 PM

Hi Ben,

Hmm . . . no, js.axd is not in the source for blog.js . . . the only *.axd reference I see is for rating.axd.

It appears that I have a function missing from the blog.js file, or a different version of it.


Sep 11, 2009 at 12:23 AM

No js.axd?  Hmm.. that's strange :)

When you deployed the project to the production site, did you just copy/FTP the files over there?  Or did you use the Publish feature in Visual Studio?  In the BIN directory, how many DLL files are there?  Just the BlogEngine.Core.dll file?

This may not be the issue, but if you did use the Publish feature in VS, that usually produces a bunch of DLL files into the BIN folder.  People have reported problems with how BE runs in this scenario.

You could try manually adding the <script> tag for blog.js into your site.master file (in your theme folder).  This would probably solve the problem, however there may be other problems considering js.axd isn't being injected into the page.  Adding the blog.js is as simple as adding this <script> tag into the <head> section in the site.master file.

<script type="text/javascript" src="/blog.js"></script>

Other than upgrading the project from ASP.NET 2.0 to ASP.NET 3.5 (which shouldn't be a problem), did you make any other customizations to the blog?

You could also try re-building the BE Core project in Visual Studio (this will produce a new BlogEngine.Core.dll file to be placed into the BIN directory).  I'm not sure if the BlogEngine.Core.dll file was re-built (re-compiled) after you upgraded the project to ASP.NET 3.5.