Script resource cannot be found

Topics: Customizing Orchard
Jan 5, 2012 at 7:23 AM
Edited Jan 5, 2012 at 7:26 AM

Hi, 

I created a custom theme named MyTheme and then I added search form widget in second aside zone.
I would like to add a watermark to search text field so I'm trying to use jquery watermark plugin.

I override Parts.Search.SearchForm.cshtml and then in this template, to use the plugin, I added:

Script.Include("jquery.watermark.min.js").AtHead();

I put jquery.watermark.min.js in MyTheme\Scripts folder but when I run the site, the script cannot be found.


In which folder do I have to put the script?

Jan 5, 2012 at 11:57 AM

Hi,

I found the problem: in the Scripts folder I didn't copy a web.config configured with the permissions to access the js file.
This is the web.config content:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>
  <system.web>
    <httpHandlers>
      <!-- iis6 - for any request in this location, return via managed static file handler -->
      <add path="*" verb="*" type="System.Web.StaticFileHandler" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <handlers accessPolicy="Script,Read">
      <!--
      iis7 - for any request to a file exists on disk, return it via native http module.
      accessPolicy 'Script' is to allow for a managed 404 page.
      -->
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
    </handlers>
  </system.webServer>
</configuration>

Jan 5, 2012 at 12:17 PM

Hi,

I found a better way to manage watermark: I used the new placeholder attribute available in HTML 5, so I simply customized search form template in this way:

@Html.TextBox("q", (SearchViewModel)Model.ViewModel.Query, new { placeholder = "Search" })

Unfortunately, placeholder attribute is not supported in IE 9 but it will be supported in IE 10 (see http://msdn.microsoft.com/it-it/library/hh673546(en-us,VS.85).aspx).

Coordinator
Jan 5, 2012 at 8:54 PM

Yes, but as it's not essential for the feature to work, I'd go for the simplicity of that solution. People who want a better experience should use another browser. Did I say that out loud?

Jan 6, 2012 at 5:23 AM

Hi,

I totally agree with you. With placeholder attribute is very easy to add watermark to search form instead of using a jQuery plugin.
Who wants watermark should use another browser for now but I think IE 10 is not far.