I have used this in another MVC project of mine and the code works perfect when I run that program. I'm trying to use it in my new MVC application now and I cant get it to work with the same code. I've added all of the references to jQuery and bootstrap.
The text box shows up fine, along with the glyphicon for the datetimepicker and when I hover over it the mouse changes into the hand symbol. When I click the button nothing happens at that point. Here is what my code looks like for the datetimepicker:
<div class="form-group">
#Html.LabelFor(m => m.InterviewDate, new { #class = "col-sm-2 control-label" })
<div class="col-sm-3">
<div class='input-group date' id='datetimepicker1'>
#Html.TextBoxFor(m => m.InterviewDate, new { #class = "form-control" })
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
<script type="text/javascript">
$(function () {
//$('.datepicker').datepicker({
// format: 'mm-dd-yyyy'
//});
$('#datetimepicker1').datetimepicker();
});
</script>
</div>
</div>
</div>
My _Layout page references these at the top:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>#ViewBag.Title Job Manager</title>
<link rel="stylesheet" href="~/Content/bootstrap.min.css">
<link rel="stylesheet" href="~/Content/bootstrap-theme.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="~/Content/jquery-ui.min.css">
<link rel="stylesheet" href="~/Content/jquery-ui.theme.min.css">
<link rel="stylesheet" href="~/Content/bootstrap-datetimepicker.min.css">
<style type="text/css">
body {
margin-top: 60px;
background: #d9edf7;
}
</style>
<script src="~/Scripts/jquery-2.1.3.min.js"></script>
<script src="~/Scripts/jquery-ui-1.11.4.min.js"></script>
<script src="~/Scripts/moment-with-locales.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="~/Scripts/bootstrap-datetimepicker.min.js"></script>
</head>
And then references these at the bottom:
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#RenderSection("scripts", false)
If I'm forgetting anything or you need more information please let me know. I appreciate any and all help!
Related
My <title>VARIABLE</title> include text "| website" in all my titles , I want to remove this text from my title using replace function. I have no experience of C# but need to do this work. I have checked its RAZOR framework. Please add the code between the title tag using my variable you can see in the title tag of code.
#using System.Web.Optimization
#using Sana.RazorDeface
#{
var customerServiceUrl = Url.Sana.Resolve(Shop.Settings.CustomerServicePage);
}
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js ie8"><![endif]-->
<!--[if IE 9]><html class="no-js ie9"><![endif]-->
<!--[if IE 10]><html class="no-js ie10"><![endif]-->
<html class="no-js" lang="#Sana.PageLanguage">
<!--<![endif]-->
<head>
<title>#PageInfo.Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="#Html.FormatMetaDescription(PageInfo.MetaDescription)" />
<meta name="robots" content="#PageInfo.Robots" />
<meta name="generator" content="Sana Commerce" />
#When(PageInfo.Robots.Index, render => Html.CanonicalLink())
#When(PageInfo.Robots.Index, render => Html.AlternateLinks())
#Html.Partial("_PageTracking")
#Styles.Render("~/content/css/store")
<link href="#Url.ThemeStyleSheet(PageInfo.UseDefaultTheme.GetValueOrDefault(true))" type="text/css" rel="stylesheet" />
#Html.Partial("_ExternalFonts")
#When(Sana.IsPrintMode, then => Styles.Render("~/content/css/extra/print"))
#When(Sana.IsEditorMode, then => Styles.Render("~/content/css/extra/editor"))
#When(Sana.IsProfilerEnabled, then => Styles.Render("~/content/css/extra/profiler"))
#RenderSection("Head", required: false)
#Html.EnterpriseDebugString()
#Sana.HtmlInjection("Head")
<meta name="google-site-verification" content="nbS3GoTrL6EPv9TF7RbIDwT9hpvbEb6ecPZfSsxWSzs" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-135059944-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-135059944-1');
</script>
</head>
<body class="#GetPageCssClasses()" data-url-root="#Href("~/")" data-url-home="#When(Shop.CommerceContext.NoSqlConnection, Href("~/"), Url.Sana.HomePage())" data-currency="#Shop.CommerceContext.CurrencyId">
#Html.Partial("_PageTrackingNoscript")
#Sana.HtmlInjection("BodyStart")
<div class="site">
<noscript>
<div class="msg-block no-script">
#Sana.RichText("NoScriptMessage")
</div>
</noscript>
#(Sana.IsProfilerEnabled ? Html.Partial("_Profiler") : null)
#When(Sana.IsEditorMode, render => Html.Partial("_FrontendEditorToolbar"))
<header class="nav-is-closed">
<div class="header-blocks-wrapper">
<div class="top-header">
#Html.Partial("_HeaderInfoMessage")
<div class="top-action">
#RenderSection("Language", required: false)
#if (!customerServiceUrl.IsEmptyString())
{
#Sana.SimpleText("CustomerService")
}
#RenderSection("Login", required: false)
</div>
</div>
<div class="middle-header">
#RenderSection("Logo", required: false)
#RenderSection("Search", required: false)
#RenderSection("Basket", required: false)
</div>
<div class="bottom-header">
<div class="center">
<div class="nav-opener-wrapper">
<div class="nav-opener"></div>
</div>
#RenderSection("TopMenu", required: false)
</div>
</div>
</div>
</header>
<div class="school-selection-header">
#RenderSection("TopSchoolSelection", required: false)
</div>
<div class="content">
#RenderBody()
</div>
<footer>
<div class="center">
<div class="columns-general top">
#RenderSection("Sitemap", required: false)
#RenderSection("Newsletter", required: false)
</div>
<div class="columns-general bottom">
#RenderSection("Footer", required: false)
</div>
</div>
</footer>
#Html.Partial("LoadingIndicator")
</div>
#Html.AntiForgeryToken()
#Scripts.RenderFormat("<script defer src=\"{0}\"></script>", "~/content/script/libs")
#Scripts.RenderFormat("<script defer src=\"{0}\"></script>", "~/content/script/shop")
#if (Sana.IsProfilerEnabled)
{
#Html.ProfilerIncludes()
#Scripts.RenderFormat("<script defer src=\"{0}\"></script>", "~/content/script/profiler")
}
#When(Sana.IsEditorMode, render => Html.Partial("_FrontendEditorScripts"))
#RenderSection("Scripts", false)
#DefaceScripts.Profiler(Context)
#Sana.HtmlInjection("BodyEnd")
</body>
</html>
Try this. Hope this works.
<title>#PageInfo.Title.Replace("| website"," ")</title>
When I add layout on all pages in my Asp.net mvc project, all methods are called three times. But this problem is solved when I set the layout page setting to null. I am not quite sure if this problem stems from the layout page, but I absolutely have to solve it. Because the log and all other structures are working three times, and I have a lot of problems with tempdata.
#using System.Web.Mvc.Html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>#ViewBag.Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport" />
<meta content="" name="author" />
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css" />
<link href="~/Content/Theme/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Theme/assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Theme/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Theme/assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Theme/assets/global/plugins/bootstrap-select/css/bootstrap-select.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Theme/assets/global/plugins/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Theme/assets/global/plugins/bootstrap-sweetalert/sweetalert.css" rel="stylesheet" />
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN THEME GLOBAL STYLES -->
<link href="~/Content/Theme/assets/global/css/components-md.min.css" rel="stylesheet" id="style_components" type="text/css" />
<link href="~/Content/Theme/assets/global/css/plugins-md.min.css" rel="stylesheet" type="text/css" />
<!-- END THEME GLOBAL STYLES -->
<!-- BEGIN THEME LAYOUT STYLES -->
<link href="~/Content/Theme/assets/layouts/layout3/css/layout.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Theme/assets/layouts/layout3/css/themes/default.min.css" rel="stylesheet" type="text/css" id="style_color" />
<link href="~/Content/Theme/assets/layouts/layout3/css/custom.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Theme/assets/pages/css/error.min.css" rel="stylesheet" />
<!-- END THEME LAYOUT STYLES -->
</head>
<!-- END HEAD -->
<body class="page-container-bg-solid page-md">
<div class="page-wrapper">
<div class="page-wrapper-row">
<div class="page-wrapper-top">
<!-- BEGIN HEADER -->
<div class="page-header">
<!-- BEGIN HEADER TOP -->
<div class="page-header-top">
<div class="container">
<!-- BEGIN LOGO -->
<div class="page-logo">
<a>
<img src="~/Content/Theme/arcelik-logo.png" alt="logo" class="logo-default">
</a>
</div>
<!-- END LOGO -->
<!-- BEGIN RESPONSIVE MENU TOGGLER -->
#**#
<!-- END RESPONSIVE MENU TOGGLER -->
<!-- BEGIN TOP NAVIGATION MENU -->
<div class="top-menu" style="display:inline-block; vertical-align:middle;">
<ul class="nav navbar-nav pull-right" style="line-height:50px;">
<li class="dropdown dropdown-user dropdown-dark">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
<span class="username username-hide-mobile">#Html.Action("GetLoggedUserName", "Account")</span>
</a>
</li>
<li class="dropdown dropdown-separator">
<span class="separator"></span>
</li>
<li class="dropdown">
#using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { #class = "login-form", id = "logoffForm" }))
{
#Resources.Global.Logout<i class="icon-logout"></i>
}
</li>
</ul>
</div>
<!-- END TOP NAVIGATION MENU -->
</div>
</div>
<div class="page-header-menu visible-desktop visible-tablet visible-phone">
<div class="container"></div>
</div>
</div>
<!-- END HEADER -->
</div>
</div>
<div class="page-wrapper-row full-height">
<div class="page-wrapper-middle">
<!-- BEGIN CONTAINER -->
<div class="page-container">
<!-- BEGIN CONTENT -->
<div class="page-content-wrapper">
<div class="page-content">
<div class="container-fluid">
<div class="page-content-inner">
#RenderBody()
</div>
</div>
</div>
<!-- END PAGE CONTENT BODY -->
<!-- END CONTENT BODY -->
</div>
<!-- END CONTENT -->
</div>
<!-- END CONTAINER -->
</div>
</div>
</div>
<!--[if lt IE 9]>
<script src="../assets/global/plugins/respond.min.js"></script>
<script src="../assets/global/plugins/excanvas.min.js"></script>
<script src="../assets/global/plugins/ie8.fix.min.js"></script>
<![endif]-->
<!-- BEGIN CORE PLUGINS -->
<script src="~/Content/Theme/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="~/Content/Theme/assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="~/Content/Theme/assets/global/plugins/js.cookie.min.js" type="text/javascript"></script>
<script src="~/Content/Theme/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="~/Content/Theme/assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="~/Content/Theme/assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript"></script>
<script src="~/Content/Theme/assets/global/plugins/bootstrap-select/js/bootstrap-select.min.js" type="text/javascript"></script>
<script src="~/Content/Theme/assets/global/plugins/jstree/dist/jstree.min.js" type="text/javascript"></script>
<script src="~/Content/Theme/assets/global/plugins/bootstrap-sweetalert/sweetalert.js"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN THEME GLOBAL SCRIPTS -->
<script src="~/Content/Theme/assets/global/scripts/app.min.js" type="text/javascript"></script>
<!-- END THEME GLOBAL SCRIPTS -->
<script src="~/Content/Theme/assets/pages/scripts/components-bootstrap-select.min.js" type="text/javascript"></script>
<!-- BEGIN THEME LAYOUT SCRIPTS -->
<script src="~/Content/Theme/assets/layouts/layout3/scripts/layout.min.js" type="text/javascript"></script>
<script src="~/Content/Theme/assets/layouts/layout3/scripts/demo.min.js" type="text/javascript"></script>
<script src="~/Content/Theme/assets/layouts/global/scripts/quick-sidebar.min.js" type="text/javascript"></script>
<script src="~/Content/Theme/assets/layouts/global/scripts/quick-nav.min.js" type="text/javascript"></script>
<!-- END THEME LAYOUT SCRIPTS -->
<script type="text/javascript">
//$('.bs-select').selectpicker({});
</script>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#RenderSection("scripts", required: false)
</body>
</html>
To give an example, the users come to my page via the Crm system with the following action.
[AllowAnonymous]
public ActionResult ToFolder(CrmIntegrationModel crmIntegrationModel)
{
if (!ModelState.IsValid) return ErrorView(new Exception(ModelState.ToErrorString()));
if (crmIntegrationModel.EntityGuid == Guid.Empty) return ErrorView(new ArgumentNullException(nameof(crmIntegrationModel.EntityGuid)));
if (crmIntegrationModel.UserId == Guid.Empty) return ErrorView(new ArgumentNullException(nameof(crmIntegrationModel.UserId)));
if (string.IsNullOrWhiteSpace(crmIntegrationModel.EntityName)) return ErrorView(new ArgumentNullException(nameof(crmIntegrationModel.EntityName)));
var applicationPath = Request.ApplicationPath == "/" ? "/" : Request.ApplicationPath + "/";
TempData["CrmIntegrationModel"] = crmIntegrationModel;
return RedirectToAction("Login", "Account", new RouteValueDictionary(new { userId = crmIntegrationModel.UserId, userType = crmIntegrationModel.UserType }));
}
If the incoming model is correct, I'm redirecting the following action to login.
[AllowAnonymous]
public ActionResult Login(Guid userId,UserType userType)
{
IAccount account = null;
if (userType == UserType.SystemUser)
account = _accountService.CheckSystemUser(userId);
if (userType == UserType.Employee)
account = _accountService.CheckEmployee(userId);
if (account == null) throw new Exception(ErrorMessages.UserNotFound);
var roles = account.Roles.ToArray();
var principalModel = new CustomPrincipalViewModel
{
UserId = account.UserId.ToString(),
FullName = account.FullName,
Roles = roles,
Language = account.Language
};
var userData = JsonConvert.SerializeObject(principalModel);
var ticket = new FormsAuthenticationTicket(1, principalModel.FullName, DateTime.Now, DateTime.Now.AddMinutes(30), false, userData);
var encryptedTicket = FormsAuthentication.Encrypt(ticket);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.Cookies.Add(cookie);
SetCulture(account.Language.CultureCode);
return RedirectToAction("RedirectToFolder","Upload");
}
After the login process, the following action is repeated three times.
public ActionResult RedirectToFolder()
{
var crmIntegrationModel = TempData["CrmIntegrationModel"] as CrmIntegrationModel;
if (crmIntegrationModel == null) return ErrorView(new ArgumentNullException($"crmIntegrationModel"));
_entityId = crmIntegrationModel.EntityGuid;
_systemUser = crmIntegrationModel.UserId.ToString();
_portalEntity = _verifyService.VerifyEntity(crmIntegrationModel.EntityName, crmIntegrationModel.EntityGuid);
_folderPath = _portalEntity.FolderPath;
try
{
var folder = _sharePointFolderService.GetFolderByTitle(_portalEntity.FolderPath);
Session["OpenedFolderId"] = folder.ParentFolderId;
Session["SelectedFolderId"] = folder.Id;
Session["DocumentTypeId"] = _portalEntity.DocumentTypeId != Guid.Empty && _portalEntity.EntityType == EntityType.Case ? (object)_portalEntity.DocumentTypeId : "-1";
Session["Entity"] = _portalEntity;
return _portalEntity.EntityType == EntityType.Policy ? RedirectToAction("Index", "Policy") : RedirectToAction("Index");
}
catch (Exception ex)
{
return ErrorView(ex);
}
}
EDIT :
I cannot solve this problem. Removed everything in _layout page one by one but nothing is changed. Could anyone help with remote connection, please ?
LAYOUT
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- Apple devices fullscreen -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- Apple devices fullscreen -->
<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>New Indus Goods - Loagin</title>
<link rel="stylesheet" type="text/css" href="#Url.Content("~/css/bootstrap.min.css")"/>
<link rel="stylesheet" type="text/css" href="#Url.Content("~/css/plugins/icheck/all.css")"/>
<link rel="stylesheet" type="text/css" href="#Url.Content("~/css/style.css")"/>
<link rel="stylesheet" type="text/css" href="#Url.Content("~/css/themes.css")"/>
<link href="#Url.Content("~/Styles/view_specific_style.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="#Url.Content("~/js/jquery.min.js")"></script>
<script type="text/javascript" src="#Url.Content("~/js/plugins/nicescroll/jquery.nicescroll.min.js")"></script>
<script type="text/javascript" src="#Url.Content("~/js/plugins/validation/jquery.validate.min.js")"></script>
<script type="text/javascript" src="#Url.Content("~/js/plugins/validation/additional-methods.min.js")"></script>
<script type="text/javascript" src="#Url.Content("~/js/plugins/icheck/jquery.icheck.min.js")"></script>
<script type="text/javascript" src="#Url.Content("~/js/bootstrap.min.js")"></script>
<script type="text/javascript" src="#Url.Content("~/js/eakroko.js")"></script>
<!--[if lte IE 9]>
<script type="text/javascript" src="#Url.Content("~/js/plugins/placeholder/jquery.placeholder.min.js")"></script>
<script>
$(document).ready(function() {
$('input, textarea').placeholder();
});
</script>
<![endif]-->
<!-- Favicon -->
<link rel="shortcut icon" href="~/img/favicon.ico" />
<!-- Apple devices Homescreen icon -->
<link rel="apple-touch-icon-precomposed" href="~/img/apple-touch-icon-precomposed.png" />
</head>
<body class='login'>
<div class="wrapper">
<h1>
<a href="index.html">
<img src="#Url.Content("~/img/logo-big.png")" alt="" class='retina-ready' width="59" height="49">New Indus Goods</a>
</h1>
<div id="body" class="login-body">
#RenderSection("featured",required:false)
<section class="content-wrapper">
#RenderBody()
</section>
</div>
</div>
</body>
</html>
VIEW
#model Test1.Models.UserProfile
#{
Layout = "~/Views/_LayoutPage1.cshtml";
ViewBag.Title = "Index";
Test1.Models.UserProfile lol = ViewBag.Profile;
}
#section featured
{
#using (Html.BeginForm("Index", "Input"))
{
#Html.ValidationSummary(true)
<fieldset>
<div class="content-wrapper">
<div class="form-group">
<div class="email controls">
#Html.EditorFor(model => model.Name, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.Name)
</div>
</div>
</div>
<p>lol what is is</p>
</fieldset>
<p>
<input type="submit" value="Save" />
</p>
}
}
<div>
#Html.ActionLink("Back To Index", "Index");
</div>
Server side validation is performed but client side is not happening! please tell me what am I missing here?? I have tried finding a solution on Google but failed. I am new to MVC so kindly help me! Page goes back for POST then come back and says Name field is required, why it is not validating before POSTING BACK??
i had to add
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
in page-related web.config too :)
I am using this post to disable my buttons on click:
Prevent multiple form submits in MVC 3 with validation
This is my page source after it is rendered:
<!DOCTYPE html>
<html>
<head>
<title>Do not bookmark this page.</title>
<link href="/Content/reset.css" rel="stylesheet" type="text/css" />
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
<link href="/Content/styer.css?t=335" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="/Scripts/Views/main.js" type="text/javascript"></script>
<link rel="shortcut icon" href="/Content/favicon.ico" type="image/ico" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<script language="javascript" type="text/javascript">
$(function () {
$('form').submit(function () {
if ($(this).valid()) {
$('input[type="submit"]').attr('disabled', 'disabled');
}
});
});
</script>
</head>
<body>
<div class="page">
<div id="header">
<div id="headerimg"></div>
<div id="logindisplay">
[ Log On ]
</div>
<div id="menucontainer">
<ul id="menu">
<li>Home</li>
<li>Logon</li>
<li>Register</li>
<li>Contact Us</li>
<li>News</li>
</ul>
</div>
<div id="main">
<h2>Forgot Username</h2>
<p>
Please provide the email address on your web account. Once validated, your username will be sent to your email address for your records.
</p>
<script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<form action="/Account/ForgotUsername" method="post"> <div>
<fieldset>
<legend>Email address</legend>
<div class="editor-label">
<label for="EmailAddress">Email</label>
</div>
<div class="editor-field focus">
<input class="GenericTextBox" data-val="true" data-val-length="The Email must be at least 7 characters long." data-val-length-max="100" data-val-length-min="7" id="EmailAddress" name="EmailAddress" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="EmailAddress" data-valmsg-replace="true"></span>
</div>
<p>
<input id="btn" class="makePaymentInput" type="submit" value="Submit"/>
</p>
</fieldset>
</div>
</form>
<div style="clear: both;"></div>
</div>
<div id="footer">
</div>
</div>
</div>
<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project = 9150358;
var sc_invisible = 1;
var sc_security = "1af31df9";
var scJsHost = (("https:" == document.location.protocol) ? "https://secure." : "http://www.");
document.write("<sc" + "ript type='text/javascript' src='" + scJsHost + "statcounter.com/counter/counter.js'></" + "script>");
</script>
<noscript>
<div class="statcounter"><a title="web analytics" href="http://statcounter.com/" target="_blank"><img class="statcounter" src="http://c.statcounter.com/9150358/0/1af31df9/1/" alt="web analytics"></a></div>
</noscript>
<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
{"appName":"Internet Explorer"}
</script>
<script type="text/javascript" src="http://localhost:25759/610299fe88d74cee8d0267b4fc859da0/browserLink" async="async"></script>
<!-- End Browser Link -->
</body>
</html>
This works on most forms but this one, which is the main reason I used this code.
Anyone see why this one is not working?
Instead of writing this :-
$('input[type="submit"]').attr('disabled', 'disabled');
You should write this :-
$('input[type="submit"]').prop('disabled','true');
For some reason my Telerik MVC Editor() is not working. Can anyone spot what I´m doing wrong?
I´m using MVC4 with Razor view engine and Telerik version 2012.1.214
_Layout.cshtml includes this:
#using Smekklegt.Models
#using Telerik.Web.Mvc.UI
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="is" xml:lang="is">
<head>
<meta charset="utf-8" />
<title>#ViewBag.Title</title>
<link href="#Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="#Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery-ui-1.8.20.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/modernizr-2.5.3.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/AjaxLogin.js")" type="text/javascript"></script>
<meta name="viewport" content="width=device-width" />
<!-- Skrár frá template-->
<link href="#Url.Content("~/Content/rikona/styles/galleriffic.css")" rel="stylesheet" type="text/css" />
<link href="#Url.Content("~/Content/rikona/style.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Content/rikona/js/jquery-1.3.2.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Content/rikona/js/jquery.opacityrollover.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Content/rikona/js/jquery.galleriffic.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Content/rikona/js/gallery-settings.js")" type="text/javascript"></script>
<!--[if IE 6]>
<script src="../../Content/rikona/js/ie6-transparency.js"></script>
<script>
DD_belatedPNG.fix('#header .logo img, .subtitle img, .slideshow-container, .navigation-container #thumbs .thumbs li .thumb img, .navigation a.next, .footer-line, #sidebar .author-photo, .line, .commentlist .comment-reply-link, #contact-page #contact .submit');
</script>
<link rel="stylesheet" type="text/css" href="../../Content/rikona/styles/ie6.css" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="../../Content/rikona/styles/ie7.css" />
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="../../Content/rikona/styles/ie8.css" />
<![endif]-->
#(Html.Telerik().StyleSheetRegistrar()
.DefaultGroup(group => group
.Add("telerik.common.css")
.Add("telerik.simple.css")
.Combined(true)
.Compress(true))
)
</head>
<body>
<div id="wrap">
<div id="header">
<section id="login" style="float: right;">
#Html.Partial("_LogOnPartial")
</section>
<section style="float: left;">
<ul>
<li>#Html.ActionLink("Flokkar", "Index", "Category")</li>
<li>#Html.ActionLink("Vörur", "Index", "Product")</li>
</ul>
</section>
<div class="logo">
<img src="../../Content/rikona/images/smekklegt_banner2.jpg" alt="logo" width="400px;" />
</div>
<div id="nav">
<ul id="nav-pages">
<li>#Html.ActionLink("Forsíða", "Index", "Home")<span>|</span></li>
#foreach (Category category in (IEnumerable<Category>)ViewData["Categories"])
{
<li>#Html.ActionLink(category.Name, "FindProductsByCategory", "Product", new { catId = category.Id }, null)<span>|</span></li>
}
<li>#Html.ActionLink("smekklegt.is", "Contact", "Home")</li>
</ul>
</div>
</div>
<div id="frontpage-content">
<div id="container">
#RenderSection("featured", false)
<section class="content-wrapper main-content clear-fix">
#RenderBody()
</section>
</div>
</div>
<div id="footer" style="margin-top: 15px;">
<div class="footer-line">
</div>
<p>
© #DateTime.Now.Year Smekklegt ehf</p>
<div class="float-right">
<ul id="social">
<li>Facebook</li>
</ul>
</div>
</div>
#Html.Telerik().ScriptRegistrar().jQuery(false).DefaultGroup(g => g.Combined(true).Compress(true))
</div>
Create.cshtml includes this:
#using Telerik.Web.Mvc.UI
#model Smekklegt.Controllers.ProductFormViewModel
#{
ViewBag.Title = "Create";
}
<h2>Create</h2>
<script type="text/javascript" src="#Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script type="text/javascript" src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
#using (Html.BeginForm()) {
#Html.ValidationSummary(true)
<fieldset>
<legend>Product</legend>
<div class="editor-label">
#Html.LabelFor(model => model.Product.Name)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.Product.Name)
#Html.ValidationMessageFor(model => model.Product.Name)
</div>
<div class="editor-label">
#Html.LabelFor(model => model.Product.FK_Category)
</div>
<div class="editor-field">
#*#Html.EditorFor(model => model.Product.FK_Category)*#
#Html.DropDownListFor(d => d.Categories, new SelectList(Model.Categories, "Id", "Name"))
#Html.ValidationMessageFor(model => model.Product.FK_Category)
</div>
<div class="editor-label">
#Html.LabelFor(model => model.Product.Description)
</div>
<div>
#{ Html.Telerik().EditorFor(m => m.Product.Description)
.Name("ProductCreateEditor")
.Encode(false)
.HtmlAttributes(new { style = "width: 500px;" })
.Tools(t => t.Clear()
.Bold().Italic().Underline().Separator().JustifyCenter().JustifyLeft().JustifyRight().JustifyFull())
//.Value((string)ViewData["ProductDescription"])
.Render(); }
</div>
<p>
<input type="submit" value="Stofna" />
<input type="button" value="Til baka" onclick="javascript:history.go(-1)"/>
</p>
</fieldset>
}
The problem I have is that every time I load my page the telerik editor appears but I can not write into the text area. (It looks like it were disabled) :(
Update
Remove this line from your Layout
<script src="#Url.Content("~/Content/rikona/js/jquery-1.3.2.js")" type="text/javascript"></script>
You only need one version of Jquery, they are conflicting is my best bet.
Everything else looks right
Remove this line
.Value((string)ViewData["ProductDescription"])
You are using EditorFor which pulls the value out of the model. So you only need to set the value in one place. You were trying to set it in two places, in the EditorFor and Value.
If you were using just Editor not EditorFor you can use Value
So choose to do EditorFor like so:
#{ Html.Telerik().EditorFor(m => m.Product.Description)
.Name("ProductCreateEditor")
...
.Render();
}
Or Editor
#{ Html.Telerik().Editor()
.Name("ProductCreateEditor")
...
.Value((string)ViewData["ProductDescription"])
.Render();
}
As John also states make sure the placement of your Telerik script is in the right place. It must be in the _Layout page at the bottom like so;
#(Html.Telerik().ScriptRegistrar().jQuery(false).DefaultGroup(group => group.Combined(true).Compress(true)))
</body>
</html>