I have the following view definition in my asp.net mvc website:
<% Using Ajax.BeginForm("UsrCtlChangePassword", "User", Nothing, New AjaxOptions With {.UpdateTargetId = "resultDiv", .InsertionMode = InsertionMode.Replace, .HttpMethod = "Post"}, New With {.id = "myFormID"})%>
<%: Html.ValidationSummary(True, "Invalid details supplied.")%>
...View field definition in here
...
<% End Using%>
</div>
So basically when the user enters invalid information (old password doesn't match) the whole page isn't refreshed just the targetdiv.
This works perfectly in my dev environment. The problem I have is that I have now deployed it to my web host server (softsys windows 2008 server) and it doesn't work upon the deployed server. It totally ignores the ajax insertion mode logic and just sends back the entire form.
Why would it be working in dev and not on the deployment server? I've checked all the dlls and scripts and everything seems to be there. Following is the dll's in my bin folder:
I've got the following keys set in my web.config (I changed the UnobtrusiveJavaScriptEnabled to true and it didnt make a difference):
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="false" />
And this is the script links in my site.master:
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<link href="<%: Url.Content("~/Content/themes/Redmond/jquery-ui.css")%>" rel="stylesheet" type="text/css" />
<script src="<%: Url.Content("~/Scripts/jquery-1.5.1.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/modernizr-1.7.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/jquery-ui-1.8.11.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/jquery.cookie.js") %>" type="text/javascript"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/MicrosoftAjax.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/MicrosoftMvcValidation.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/MicrosoftMvcAjax.js") %>"></script>
Any ideas?
Thanks in advance.
I worked it out, it ended up being that I needed to add the following lines to my site.master:
<% Html.EnableClientValidation()%>
<% Html.EnableUnobtrusiveJavaScript(False)%>
For some reason the keys I set in the web.config were being ignored when deployed to the webserver. As soon as I added these lines to the site master everything worked as it should.
Related
My Search.cshtml has a div named "search-results" that is to be updated. SearchResults is the action name. I have done this many times on MVC2/VS2008 projects, but this is my first using MVC3 and VS2010.
The problem is, instead of my search result being rendered in my div, it clicking submit is redirecting me displaying my partial as a standalone page.
I have read that this may be because Ajax is not enabled. My _Layout.cshtml looks like this:
<!DOCTYPE html>
<html>
<head>
<title>#ViewBag.Title</title>
<script src="#Url.Content("~/Scripts/2011.2.712/jquery-1.5.1.min.js")" type="text/javascript"></script>
<link href="#Url.Content("~/Content/themes/base/jquery.ui.core.css")" rel="stylesheet" type="text/css" />
<link href="#Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />
<link href="#Url.Content("~/Content/themes/base/jquery.ui.theme.css")" rel="stylesheet" type="text/css" />
<link href="#Url.Content("~/Content/main.css")" rel="stylesheet" type="text/css" />
<link href="#Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Scripts/2011.2.712/jquery-1.5.1.min.js")" type="text/javascript"></script>
#(Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.transparent.css").Combined(true).Compress(true)))
</head>
<body>
<div class="page">
<div id="header">
<div id="title">
<h1>My MVC Application</h1>
</div>
#(Html.Telerik().Menu()
.Name("menu")
.Items(menu => {
menu.Add().Text("Home").Action("Index", "Home");
menu.Add().Text("About").Action("About", "Home");
menu.Add().Text("Employees").Action("List", "Employee");
}))
</div>
<div id="main">
#RenderBody()
<div id="footer">
</div>
</div>
</div>
#(Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(true).Compress(true)))</body>
</html>
Do I need to add MicrosoftMvcAjax.js or jquery.unobtrusive-ajax.js in? My web.config (root) contians the following:
<appSettings>
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
If I add MicrosoftMvcAjax.js in at the end of the element, I get an error sayning namespace 'Type' is undefined error from the first line of MicrosoftMvcAjax.js:
Type.registerNamespace('Sys.Mvc');Sys.Mvc.$create_AjaxOptions=function(){return {};}
What am I missing here. I am sure my code is fine, as it copied alsmost verbatim from my MVC2 projects.
You forgot to include the jquery.unobtrusive-ajax.js script to your page (adjust the path as necessary):
<script src="#Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
As far as Microsoft*.js scripts are concerned, they are obsolete in ASP.NET MVC 3 and should no longer be used unless you are porting some legacy application. They have been replaced by jQuery.
Ok, figured out my problem.
I was calling Ajax.BeginForm with the AjaxOption OnSuccess pointint to a js function that updated my place holder. But this is not needed, with unobtrusive. Once I removed the OnSucces from the Ajax options everything started working.
~S
I am unable to make CLEditor work for me. Please find the scipt files being adding in _Layout.cshtml
<link href="#Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
<link href="#Url.Content("~/Content/jquery.cleditor.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Scripts/jquery.cleditor.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.cleditor.min.js")" type="text/javascript" ></script>
<script src="#Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type="text/javascript"></script>
#Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.vista.css"));
Partial View has given below code.
<textarea id="input" name="input"></textarea>
<script type="text/javascript">
$("#input").cleditor();
</script>
This is happing in all the browsers.
Per their site, "It is recommended that you install these files into a folder called cleditor with a subfolder called images."
I placed the folder in Scripts and then used this:
<link rel="stylesheet" type="text/css" href="#Url.Content("~/Scripts/cleditor/jquery.cleditor.css")" />
<script type="text/javascript" src="#Url.Content("~/Scripts/cleditor/jquery.cleditor.min.js")"></script>
I created NuGet package and try to install this package. In during instalation I get error:
"Name cannot begin with the '~' character, hexadecimal value 0x7E. Line 6, position 31."
My package consist _Layout.cshtml (with _Layout.cshtml.transform name) file with following content:
<head>
#RenderSection("ReportsHeader", false);
</head>
When I deleted this file the package was installed success.
in mvc project in _Layout.cshtml file in head tag:
<head>
<meta charset="utf-8" />
<title>#ViewBag.Title</title>
<link href="#Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
</head>
If I deleted
<link href="#Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
package installed but _Layout.cshtml file not modified.
How I can modify _Layout.cshtml file ?
or my be I can modify _Layout.cshtml file in install.ps1 file ?
It looks like the problem is with your quotation marks. Try using ' instead of " for the inner quotable sections something like this:
<head>
<meta charset="utf-8" />
<title>#ViewBag.Title</title>
<link href="#Url.Content('~/Content/Site.css')" rel="stylesheet" type="text/css" />
<script src="#Url.Content('~/Scripts/jquery-1.5.1.min.js')" type="text/javascript"></script>
<script src="#Url.Content('~/Scripts/modernizr-1.7.min.js')" type="text/javascript"></script>
</head>
Not sure if that syntax will work, but the use of nested " quotes looks like trouble.
I've been trying for tha tpast 24 hours to activate the facebook sharer to share multiple thumbs. here's my code :
<head>
<meta property="og:title" content="ShareThis Homepage" />
<meta property="og:type" content="Sharing Widgets" />
<meta property="og:url" content="http://www.realestatephotoexpert.com/Properties/82/centrisSmall/-1.jpg"/>
<meta property="og:description" content="New listing" />
<meta property="og:site_name" content="ShareThis" />
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">
stLight.options({
publisher:'12345',
});
</script>
</head>
<body>
<span class="st_sharethis"></span>
</body>
I managed to display 1 thumbnail using og:url, I dont even know why its working because it suppose to be the og:image. even with this work around, i cant figure how to share multiple thumb( once log-in to facebook, be able to use the left and right arrows to select thumnail.
thx for your help
I am working on a richface application and trying to evaluate the following xpath with xpather on firefox3.5. XPather does not evaluate any of the xpath though the same xpath works perfectly fine on firefox 3.6.
The page which I am testing is like -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:o="http://openfaces.org">
<head>
<script src="some source" type="text/javascript"></script>
<script src="some source" type="text/javascript"></script>
<link class="component" href="some source" rel="stylesheet" type="text/css" />
<link class="component" href="some source"
media="rich-extended-skinning" rel="stylesheet" type="text/css" />
<link class="component" href="some source" rel="stylesheet" type="text/css" />
<script type="text/javascript">window.RICH_FACES_EXTENDED_SKINNING_ON=true;</script>
<link type="text/css" href="some source" rel="stylesheet"/>
<body class="Banner" onresize="setTreePnlHeight()" onload="loadApp();">
<input type="hidden" id="dsTreeScrollPos" value="0" />
<div id="a" class="application"><form id="form" name="form" method="post" action="...">
....
</body>
</html>
If I use xpather(v1.4.5) to evaluate the simple xpath on FF3.5 like //input, it does not return any result. Is namespace causing this issue? How can i verify my xpath on FF3.5?
simple xpath on FF3.5 like //input, it
does not return any result. Is
namespace causing this issue?
Yes. If you look at your document, you have a default namespace definition there.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:o="http://openfaces.org">
This means that //input is looking for an element <input> without a namespace, whereas you should look for <input> that is in the http://www.w3.org/1999/xhtml namespace. You need to define that namespace and bind it to a prefix and then use that prefix in your XPath. like //x:input