I am new in MVC. In this page; I list the projects belonging to the "unit name" by loop. And what I want to do: I want to group projects belonging to the same "unit name". Each project has a "unit name" to which it belongs. There can be more than one project belonging to one unit. So I want to group it.
My cshtml code is as follows:
#if (Model.Projects.Any())
{
foreach (var item in Model.Projects.ToList())
{
<div class="ProjectPartialBody" data-id="#item.ID">
<div class="portlet box blue">
<div class="portlet-title">
<div class="caption">
<span><i class="glyphicon glyphicon-asterisk"></i> #item.tbl_Unit.Name</span>
</div>
<div class="tools">
</div>
<div class="actions">
Details
</div>
</div>
<div class="portlet-body">
<span><i class="fa fa-file"></i> #item.Name</span>
<span><i class="fa fa-calendar"> Contract Start and End Dates: #(item.ContractStartDate != null ? item.ContractStartDate.Value.ToString("dd.MM.yyyy") : "-") / #(item.ContractEndDate != null ? item.ContractEndDate.Value.ToString("dd.MM.yyyy") : "-")</i></span>
<div class="well">
<div class="form-group">
<label>Cash Completion Rate: %#item.CashCompletionRate</label>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" role="progressbar" style="width: #(item.CashCompletionRate)%;"></div>
</div>
</div>
</div>
<div class="well">
<div class="form-group">
<label>Physical Completion Rate: %#item.PhysicalCompletionRate</label>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" role="progressbar" style="width: #(item.PhysicalCompletionRate)%;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
}
}
And the view of the page is as follows (my view is in Turkish language but you'll understand what I am talking about):
My Page View
Can you please help me? And if there is any other code block you want to insert, please tell me.
You first need to group by in your for statement:
foreach(var unitGroup in Model.Projects.GroupBy(g => g.tbl_Unit.Name))
{
//...your MVC markup here
}
Now you actualy need to change the markup as you would need to put in another foreach loop that would generate markup for projects.
So something simillar to this.
<div class="ProjectPartialBody" data-id="#item.ID">
<div class="portlet box blue">
<div class="portlet-title">
<div class="caption">
<span><i class="glyphicon glyphicon-asterisk"></i> #item.tbl_Unit.Name</span>
</div>
<div class="tools">
</div>
<div class="actions">
Details
</div>
</div>
#foreach(var project in unitGroup.ToList())
{
<div class="portlet-body">
<span><i class="fa fa-file"></i> #project.Name</span>
<span><i class="fa fa-calendar"> Contract Start and End Dates: #(project.ContractStartDate != null ? project.ContractStartDate.Value.ToString("dd.MM.yyyy") : "-") / #(project.ContractEndDate != null ? project.ContractEndDate.Value.ToString("dd.MM.yyyy") : "-")</i></span>
<div class="well">
<div class="form-group">
<label>Cash Completion Rate: %#project.CashCompletionRate</label>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" role="progressbar" style="width: #(project.CashCompletionRate)%;"></div>
</div>
</div>
</div>
<div class="well">
<div class="form-group">
<label>Physical Completion Rate: %#project.PhysicalCompletionRate</label>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" role="progressbar" style="width: #(project.PhysicalCompletionRate)%;"></div>
</div>
</div>
</div>
</div>
}
</div>
</div>
There should be some errors here as I am not very familliar with your model but this should be the general idea behind it.
after navigate to a subpage i would like to close the left menu, but the app throw the "uib_sb is not defined".
how do i close the menu?
this the code to navigate:
$(document).on("click", ".uib_w_5", function(evt)
{
activate_subpage("#page_83_54");
uib_sb.close_all_sidebars();
});
this is the menu:
<nav class="af-sidemenu outer-element uib_w_2" data-side="left" id="uib_w_2" data-uib="app_framework/side_menu_area" data-ver="2">
<div class="view active">
<header class="container-group outer-element uib_w_3" data-uib="app_framework/header" data-ver="3" id="af-header-1">
<h1>Prova</h1>
<div class="widget-container wrapping-col single-centered"></div>
<div class="widget-container content-area horiz-area wrapping-col header-left"></div>
<div class="widget-container content-area horiz-area wrapping-col header-right"></div>
</header>
<div class="pages">
<div class="panel active">
<div class="col uib_col_1 single-col" data-uib="layout/col" data-ver="0">
<div class="widget-container content-area vertical-col">
<ul class="list widget uib_w_4 d-margins" data-uib="app_framework/listview" data-ver="2">
<li class="widget uib_w_5" data-uib="app_framework/listitem" data-ver="2"><a>ricerca per produttore</a>
</li>
<li class="widget uib_w_6" data-uib="app_framework/listitem" data-ver="2"><a>ricerca per scheda</a>
</li>
</ul>
<span class="uib_shim"></span>
</div>
</div>
</div>
</div>
</div>
</nav>
i found this:
$.afui.drawer.hide ("#uib_w_2", "left");
I have searched multiple examples and have tried several things to get this to work properly. Currently I am trying to get a div to be replaced by using an Ajax.HtmlLink pointing to a PartialViewResult method.
I have tried
Checking network and javascript consoles to make sure my .js are all being loaded
Unbundling the stock jqueryval bundle and including the scripts manually
Double checked I didn't have another DOM element with the same update target Id
Checked my ajaxoptions to ensure everything was correct
I know unobtrusive is working because my Email duplicate remote validation check is working.
I will now show some screen shots of my debugging process
Here is what the page looks like prior to ajax load
My goal is to replace the container on the right that is currently holding email, name, and zipcode values
Here is the result##
This is what my view code looks like
<div class="container">
<br />
<br />
<div class="row">
<div class="col-sm-3">
<div class="sidebar-account">
<div class="row ">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">My Account</div>
<div class="panel-body">
<ul class="nav">
<li>
<a class="active" href="account_dashboard.html">Me</a>
</li>
<li>
#Ajax.ActionLink("Alerts", "ManageAlerts", null, new AjaxOptions
{
HttpMethod = "GET",
UpdateTargetId = "ajax-update",
InsertionMode = InsertionMode.Replace,
OnBegin = "ajaxBegin",
OnFailure = "ajaxFail",
OnComplete = "ajaxComplete",
OnSuccess = "ajaxSuccess"
}, new { #class = "active" })
</li>
<li>
<a class="active" href="account_account.html">Linked Accounts</a>
</li>
<li>
<a class="active" href="account_ads.html">Manage ads</a>
</li>
<li>
<a class="active" href="account_ad_create.html">Create new ad</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="row hidden-xs">
<div class="col-lg-12">
<div class="well">
<div class="row ">
<div class="col-lg-3">
<img src="css/images/icons/Crest.png" width="45" />
</div>
<div class="col-lg-9">
<h4 style="margin-top: 0">Increase visibility</h4>
<p>Don't forget to 'bump' your listing to gain more visibility</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-9">
<div id="ajax-update">
#Html.Partial("_ManageUserAccount", Model)
</div>
</div>
<br />
</div>
Partial View Code##
<div id="fadein-div">
<div class="panel panel-default">
<div class="panel-heading">#Model.Username : Alerts</div>
<div class="panel-body">
<br />
<div class="row">
<div class="col-sm-12">
<p><span style="font-weight:bold">Change your alerts!</span></p>
</div>
</div>
<br />
#using (Html.BeginForm("ManageAlerts", "Account", FormMethod.Post, new { #class = "form-vertical", role = "form" }))
{
#Html.AntiForgeryToken()
<fieldset>
<div class="row">
<div class="col-sm-12 ">
<div class="form-group">
<div class="row">
<div class="col-sm-2">
<div class="checkbox">
#Html.CheckBoxFor(P => P.EmailAlertsOn) #Html.LabelFor(P => P.EmailAlertsOn)
</div>
</div>
</div>
</div>
<div id="control-div">
<div class="form-group">
<h3>Email alert options</h3>
</div>
<div class="form-group">
<div class="checkbox">
#Html.CheckBoxFor(P => P.EmailOnNewMessageOn) #Html.LabelFor(P => P.EmailOnNewMessageOn)
</div>
<div class="text-danger">
#Html.ValidationMessageFor(P => P.EmailOnNewMessageOn)
</div>
</div>
<div class="form-group">
<div class="checkbox">
#Html.CheckBoxFor(P => P.EmailOnReplyOn) #Html.LabelFor(P => P.EmailOnReplyOn)
</div>
<div class="text-danger">
#Html.ValidationMessageFor(P => P.EmailOnReplyOn)
</div>
</div>
<div class="form-group">
<div class="checkbox">
#Html.CheckBoxFor(P => P.EmailOnAccountUpdateOn) #Html.LabelFor(P => P.EmailOnAccountUpdateOn)
</div>
<div class="text-danger">
#Html.ValidationMessageFor(P => P.EmailOnAccountUpdateOn)
</div>
</div>
</div>
<br />
<button type="submit" class="btn btn-primary">Save details</button>
</div>
</div>
</fieldset>
}
</div>
</div>
And finally, controller code##
[HttpGet]
public PartialViewResult ManageAlerts()
{
var user = UserManager.FindById(Guid.Parse(User.Identity.GetUserId()));
Models.Account.ManageAlertsViewModel vm = new ManageAlertsViewModel();
vm.Username = user.UserName;
vm.EmailAlertsOn = user.EmailAlertsOn;
vm.EmailOnAccountUpdateOn = user.EmailOnAccountUpdateOn;
vm.EmailOnNewMessageOn = user.EmailOnNewMessageOn;
vm.EmailOnReplyOn = user.EmailOnReplyOn;
return PartialView("_ManageAlerts", vm);
}
<!-- js library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/bootstrap.min.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/jquery.icheck.min.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/waypoints.min.js"></script>
<!-- authenty js -->
<script src="~/Themes/Authenticity%20Forms/Authenty/js/authenty.js"></script>
<!-- preview scripts -->
<script src="~/Themes/Authenticity%20Forms/Authenty/js/preview/jquery.malihu.PageScroll2id.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/preview/jquery.address-1.6.min.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/preview/scrollTo.min.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/preview/init.js"></script>
#Scripts.Render("~/bundles/jqueryval")
I want to download xml file from url. I upload my xml file to google drive and share that file in public.
content of file is
<testapp><welcomePage><logoimage>mspeller</logoimage>
<titleBackgroudColor>yellow</titleBackgroudColor><aboutUsIcon>Speller</aboutUsIcon><allitemIcon>Speller</allitemIcon><welBackgroundcolor>red</welBackgroundcolor>
</welcomePage>
<user><userName>mgdan</userName><firstName>Mila</firstName><lastName>Gdan</lastName>
</user></testapp>
I am downloading this file using url
NSURL *url = [NSURL URLWithString:#"https://drive.google.com/file/d/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU/edit?usp=sharing"];
NSData *data = [NSData dataWithContentsOfURL:url]; // Load XML data from web
NSString *applicationDocumentsDir =
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:#"config.xml"];
// write to file atomically (using temp file)
[data writeToFile:storePath atomically:TRUE];
But the downloaded xml is look like this It returns full raw data from google what i am doing wrong
<!DOCTYPE html>
<html>
<head>
<meta content="notranslate" name="google">
<meta content="IE=edge;" http-equiv="X-UA-Compatible">
<meta content="!" name="fragment">
<title>Configuration.xml - Google Drive</title>
<style type="text/css">
#gbar,#guser{font-size:13px;padding-right:8px;padding-top:4px !important;}#gbar{padding-left:8px;height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}
</style>
<script>
_docs_flag_initialData={"jobset":"prod","docs-aiiws":"docs_warm_nf","info_params":{},"uls":"","icso":false,"docs_eoal":true,"docs_oogt":"NONE","docosEmbedApiJs":"\/\/docs.google.com\/comments\/d\/AAHRpnXsdSRJZ13fxD9ua--NCPBLpfm_dXJQy6rzoRrqyXgd3mTwXptKPl7zGQiWOqXq6aNam3ciYM4NHJ_Yrw4pg12iznl3KqA\/api\/js?hl=en_GB","docosUnreadCommentsEnabled":false,"docs-egc":true,"docs-chat_base_url":"talkgadget.google.com\/talkgadget\/","docs-chat_domain_rotation":true,"docs-ce":true,"docs-ut":2,"promo_url":"","promo_title":"","promo_title_prefix":"","promo_content_html":"","promo_element_id":"","promo_orientation":1,"promo_show_on_click":false,"promo_show_on_load":false,"show_promo":false,"docs-encp":false,"buildLabel":"texmex_2013-49-Thu_RC1","buildClNumber":"57718063","debugTask":"oa_66","docs-show_debug_info":false,"dcau":"https:\/\/chrome.google.com\/webstore\/detail\/apdfllckaahabafndbhieahigkjlhalf","ondlburl":"\/\/docs.google.com","drive_url":"\/\/drive.google.com","docs-sup":"\/file","docs-uptc":["lsrp","usp","urp","utm_source","utm_medium","utm_campaign","utm_term","utm_content"],"docs-cwsd":"","docs-al":[0,1,0,1,0]
,"docs-ndt":"Untitled Texmex","docs-eit":false,"docs-spfe":true,"docs-mriim":1800000,"docs-ecc":false,"docs-mnumea":false,"docs-ess":false,"ecbsl":true,"ecid":true,"eod":true,"docs-eilb":false,"docs-pedd":true,"docs- evr":true,"docs-eir":false,"docs-enmr":false,"docs-esrd":false,"share_ui":"jfk","server_time_ms":1387864935483,"gaia_session_id":"","enable_iframed_embed_api":true,"cup":"\/folder\/d\/{folderId}\/edit","docs-fut":"\/\/docs.google.com\/#folders\/{folderId}","esid":true,"esubid":false,"docs-etbs":true,"enable_kennedy":true,"onePickImportDocumentUrl":"","opbu":"https:\/\/docs.google.com\/picker","opru":"https:\/\/docs.google.com\/relay.html","opdu":false,"ophi":"texmex","opuci":"","docs-se":false,"docs-ebcrsct":false,"docs-iror":false,"xdbcmUri":"https:\/\/docs.google.com\/file\/xdbcm.html?pli=1","xdbcfAllowXpc":true,"docs-corsbc":false,"xdbcfAllowHostNamePrefix":true,"docs-spdy":false,"enable_client_docos":true,"enable_anchored_docos":true,"enable_docos_tickle":true,"gv_int_native":true,"enable_a11y":true,"tpc":true,"enable_pinned_revisions":false,"enable_edit_blob_revisions":false,"upload_url":"https:\/\/docs.google.com\/upload\/resumableupload","enable_toolbar":true,"enable_feedback_button":false,"enable_microscope":true,"enable_manage_timed_text":true,"video_embed_type":"PREFER_FLASH","enable_maps_embed":true,"maps_api_uri":"https:\/\/maps.googleapis.com\/maps\/api\/js?key=AIzaSyBCjpnguVjzi6vS67NdBtyYuvCYz3yBxCY&sensor=false","maps_display_uri":"https:\/\/maps.google.com\/maps","docs_abuse_link":"https:\/\/docs.google.com\/abuse?id=0B-3M5xTcGgbLYlAxR1Vqa3dRMkU","enable_csi":true,"csi_service_name":"texmex","third_party_default_icon_urls":{"icon16":"\/\/ssl.gstatic.com\/docs\/doclist\/images\/generic_app_icon_16.png","icon32":"\/\/ssl.gstatic.com\/docs\/doclist\/images\/generic_app_icon_32.png","icon64":"\/\/ssl.gstatic.com\/docs\/doclist\/images\/generic_app_icon_64.png","icon128":"\/\/ssl.gstatic.com\/docs\/doclist\/images\/generic_app_icon_128.png"},"enable_chrome_webstore_link":true};
</script>
<script type="text/javascript">
(function(){(function(){function e(a){this.t={};this.tick=function(a,c,b){var d=void 0!=b?b:(new Date).getTime();this.t[a]=[d,c];if(void 0==b)try{window.console.timeStamp("CSI/"+a)}catch(e){}};this.tick("start",null,a)}var a;window.performance&&(a=window.performance.timing);var f=a?new e(a.responseStart):new e;window.jstiming={Timer:e,load:f};if(a){var c=a.navigationStart,d=a.responseStart;0<c&&d>=c&&(window.jstiming.srt=d-c)}if(a){var b=window.jstiming.load;0<c&&d>=c&&(b.tick("_wtsrt",void 0,c),b.tick("wtsrt_",
"_wtsrt",d),b.tick("tbsd_","wtsrt_"))}try{a=null,window.chrome&&window.chrome.csi&&(a=Math.floor(window.chrome.csi().pageT),b&&0<c&&(b.tick("_tbnd",void 0,window.chrome.csi().startE),b.tick("tbnd_","_tbnd",c))),null==a&&window.gtbExternal&&(a=window.gtbExternal.pageT()),null==a&&window.external&&(a=window.external.pageT,b&&0<c&&(b.tick("_tbnd",void 0,window.external.startE),b.tick("tbnd_","_tbnd",c))),a&&(window.jstiming.pt=a)}catch(g){}})();})();
</script>
<link href="/static/file/client/css/1508097430-edit_css_ltr.css" rel=
"stylesheet">
<link href=
"https://ssl.gstatic.com/docs/doclist/images/icon_11_generic_favicon.ico"
rel="shortcut icon">
<link href=
"https://chrome.google.com/webstore/detail/apdfllckaahabafndbhieahigkjlhalf"
rel="chrome-webstore-item">
<meta content="Configuration.xml">
<meta content=
"https://ssl.gstatic.com/docs/doclist/images/icon_11_generic_favicon.ico">
<meta content=
"https://docs.google.com/file/d/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU/edit?usp=sharing&pli=1">
</head>
<body dir="ltr" onload='_onload()'>
<noscript>
<div class="docs-butterbar-container">
<div class="docs-butterbar-wrap">
<div class=
"jfk-butterBar jfk-butterBar-shown jfk-butterBar-warning">
JavaScript isn't enabled in your browser, so this file can't be
opened. Enable and reload.
</div>
</div><br>
</div></noscript>
<div class="docs-vis-ref-chrome" id="docs-chrome" tabindex="0">
<div>
<div id="docs-header">
<div class="docs-branding-default" id=
"docs-branding-container">
<a href="//drive.google.com" target="_blank" title=
"Open Google Drive"></a>
<div id="docs-drive-logo"></div>
<div id="docs-branding-logo"></div>
</div>
<div id="gbar">
<nobr><a class="gb1" href=
"https://www.google.co.in/webhp?tab=ow" target=
"_blank">Search</a> <a class="gb1" href=
"http://www.google.co.in/imghp?hl=en-GB&tab=oi" target=
"_blank">Images</a> <a class="gb1" href=
"https://maps.google.co.in/maps?hl=en-GB&tab=ol"
target="_blank">Maps</a> <a class="gb1" href=
"https://play.google.com/?hl=en-GB&tab=o8" target=
"_blank">Play</a> <a class="gb1" href=
"https://www.youtube.com/?tab=o1" target=
"_blank">YouTube</a> <a class="gb1" href=
"https://mail.google.com/mail/?tab=om" target=
"_blank">Gmail</a> <b class="gb1">Drive</b> <a class="gb1"
href="https://www.google.com/calendar?tab=oc" target=
"_blank">Calendar</a> <a class="gb1" href=
"http://www.google.co.in/intl/en-GB/options/" style=
"text-decoration:none" target="_blank"><span style=
"text-decoration: underline">More</span> »</a></nobr>
</div>
<div id="guser">
<nobr><span class="gbi" id="gbn"></span><span class="gbf"
id="gbf"></span><span id="gbe"><a class="gb4" href=
"https://docs.google.com/abuse?id=0B-3M5xTcGgbLYlAxR1Vqa3dRMkU"
target='_blank'>Report abuse</a> |</span> <a class="gb4"
href="https://docs.google.com/settings" target=
'_blank'>Settings</a> | <a class="gb4" href=
"https://www.google.com/accounts/ServiceLogin?service=wise&passive=1209600&continue=https://docs.google.com/file/d/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU/edit?usp%3Dsharing%26pli%3D1&followup=https://docs.google.com/file/d/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU/edit?usp%3Dsharing%26pli%3D1"
id="gb_70" target="_top">Sign in</a></nobr>
</div>
<div class="gbh" style="left:0"></div>
<div class="gbh" style="right:0"></div>
<div style="clear:both"></div>
<div id="docs-titlebar-container">
<div id="docs-titlebar">
<div class="docs-title-outer">
<div class="docs-title-widget goog-inline-block"
id="docs-title-widget">
<span class="docs-title" id=
"docs-title"></span>
<div class="docs-title-inner" id=
"docs-title-inner">
<span class="docs-title" id=
"docs-title">Configuration.xml</span>
</div>
</div>
<div class="docs-star-container goog-inline-block">
<div class="goog-inline-block" id="docs-star"
style="display:none"></div>
</div>
<div class=
"docs-activity-indicator-container goog-inline-block">
</div>
</div>
</div>
<div class="docs-titlebar-buttons">
<div class="goog-inline-block docs-titlebar-button" id=
"docs-presence-container">
<div class="goog-inline-block" id="docs-presence">
</div>
<div class=
"goog-inline-block jfk-button jfk-button-standard jfk-button-narrow docs-chat jfk-button-disabled"
id="docs-chat" style="display: none">
<div class="docs-icon goog-inline-block">
<div class=
"docs-icon-img-container docs-icon-img docs-icon-chat">
</div>
</div>
</div>
</div>
<div class="goog-inline-block">
<div class=
"goog-inline-block jfk-button jfk-button-standard docs-titlebar-button jfk-button-disabled"
id="docs-docos-commentsbutton">
Comments
</div>
<div id="docs-docos-caret" style="display: none">
<div class="docs-docos-caret-outer"></div>
<div class="docs-docos-caret-inner"></div>
</div>
</div><span class="goog-inline-block" id=
"docs-titlebar-share-client-button"></span>
<div class=
"goog-inline-block jfk-button jfk-button-action docs-titlebar-button jfk-button-disabled">
<span class="goog-inline-block" id=
"docs-titlebar-share-client-button"><span class=
"goog-inline-block apps-share-sprite scb-button-icon scb-unlisted-icon-white">
</span>Share</span>
</div>
</div>
</div>
</div>
<div class="docs-butterbar-container">
<div class="docs-butterbar-wrap">
<div class=
"jfk-butterBar jfk-butterBar-shown jfk-butterBar-info">
You are using an unsupported browser. Some features may
not work correctly. Upgrade to a <a class=
"docs-butterbar-link-no-pad" href=
"http://whatbrowser.org" target="_blank">modern
browser</a>, such as <a class=
"docs-butterbar-link-no-pad" href=
"https://www.google.com/chrome/?&brand=CHVN&utm_campaign=en&utm_source=en-et-na-us-docs-ug&utm_medium=et"
target="_blank">Google Chrome</a>.<a class=
"docs-butterbar-link" href="#" onclick=
"this.parentNode.parentNode.removeChild(this.parentNode);return false;">Dismiss</a>
</div>
</div><br>
</div>
</div>
<div id="docs-bars">
<div id="docs-menubars">
<div class=
"docs-menubar goog-container goog-container-horizontal" id=
"docs-menubar" tabindex="0">
<div class=
"menu-button goog-control goog-control-disabled goog-inline-block"
id="docs-file-menu">
File
</div>
<div class=
"menu-button goog-control goog-control-disabled goog-inline-block"
id="docs-edit-menu">
Edit
</div>
<div class=
"menu-button goog-control goog-control-disabled goog-inline-block"
id="docs-view-menu">
View
</div>
<div class=
"menu-button goog-control goog-control-disabled goog-inline-block"
id="docs-help-menu">
Help
</div>
</div>
<div class="docs-offscreen" id="docs-chat-message-a11y" style=
"height: 0; width: 0; overflow: hidden"></div>
<div id="docs-presence-menubar"></div>
</div>
<div id='docs-toolbar-wrapper'>
<div class="docs-collapsable-toolbar" id=
'docs-primary-toolbars'>
<div class="goog-toolbar" id="docs-toolbar">
<div class=
"goog-toolbar-button goog-inline-block goog-toolbar-button-disabled"
id="downloadToolbarButton">
<div class=
"goog-toolbar-button-outer-box goog-inline-block">
<div class=
"goog-toolbar-button-inner-box goog-inline-block">
<div class="docs-icon goog-inline-block">
<div class=
"docs-icon-img-container docs-icon-img docs-icon-download">
</div>
</div>
</div>
</div>
</div>
<div class=
"goog-toolbar-button goog-inline-block goog-toolbar-button-disabled"
id="printToolbarButton">
<div class=
"goog-toolbar-button-outer-box goog-inline-block">
<div class=
"goog-toolbar-button-inner-box goog-inline-block">
<div class="docs-icon goog-inline-block">
<div class=
"docs-icon-img-container docs-icon-img docs-icon-print">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="goog-toolbar" id="docs-side-toolbar">
<div class=
"goog-toolbar-button goog-inline-block goog-toolbar-button-disabled"
id="webstoreToolbarButton">
<div class=
"goog-toolbar-button-outer-box goog-inline-block">
<div class=
"goog-toolbar-button-inner-box goog-inline-block">
<div class="docs-icon goog-inline-block">
<div class=
"docs-icon-img-container docs-icon-img docs-icon-chrome-store">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="docs-help-anchor-wrapper">
<div id="docs-help-anchor"></div>
<div id="docs-help-anchor-right"></div>
</div>
<div id="docs-additional-bars"></div>
</div>
<div class="docs-vis-ref-editor-container" id="docs-editor-container">
<div id="docs-editor" tabindex="1">
<div class="texmex-nopreview texmex-norender">
<div class="texmex-nopreview-img"><img alt=
"No preview available" src=
"https://ssl.gstatic.com/docs/doclist/images/nopreview_blank.png"></div>
<div class="texmex-nopreview-msg">
<div>
No preview available
</div><span id="texmex-nopreview-download-span" style=
"display:none"></span>
<div class=
"goog-inline-block jfk-button jfk-button-standard texmex-nopreview-download"
tabindex="0">
<span id="texmex-nopreview-download-span" style=
"display:none"></span>
</div>
</div>
</div>
<div class="texmex-desc-container" id=
"texmex-description-container" style="display: none">
<div>
<div class="texmex-text-container" id=
"texmex-text-container">
<span class=
"texmex-contents-desc-none description_text" id=
"texmex-nodescription">Enter a description</span>
</div>
</div><span class=
"texmex-description-edit-icon goog-inline-block" id=
"texmex-description-edit-icon">
</div>
</div>
</div><script src="/static/file/client/js/3569332580-edit_core__en_gb.js"
type="text/javascript"></script>
</body>
</html>
The download url should be https://doc-10-a4-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/87pq5ptr7ncrrd8iqnu0ep6td4f4ca8q/1387864800000/06809471879824913322/*/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU?h=16653014193614665626&e=download
https://drive.google.com/file/d/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU/edit?usp=sharing is a web page.
I have a simple view:
#model BootstrapTest4.Models.Account.CambioDeClave
#{
Layout = "~/Views/Shared/SiteLayout.cshtml";
}
<h2>#Model.Title</h2>
#using (Html.BeginForm()) {
#Html.AntiForgeryToken()
#Html.ValidationSummary(true)
<fieldset>
<div class="editor-label">
#Html.LabelFor(model => model.Pass1)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.Pass1)
#Html.ValidationMessageFor(model => model.Pass1)
</div>
<div class="editor-label">
#Html.LabelFor(model => model.Pass2)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.Pass2)
#Html.ValidationMessageFor(model => model.Pass2)
</div>
<p>
<input type="submit" value="Cambiar Clave" />
</p>
</fieldset>
}
#section Scripts {
#System.Web.Optimization.Scripts.Render("~/bundles/jqueryval")
}
this view was made via the Mvc4 scaffolding system (edit template) and since I use some dataannotations in my model it uses the Scripts Bundle.
the error I am getting is the following:
The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/SiteLayout.cshtml": "Scripts"
searching I found that most people solve the problem adding this to their layout:
#if (IsSectionDefined("Scripts"))
{
RenderSection("Scripts",false);
}
I added that block just before the tag of my layout but i still get the same error.
as requested: my whole Layout:
#model BootstrapTest4.Models.IMenu
#using BootstrapTest4.Utils.Helpers
#using BootstrapTest4.Utils
#{
Layout = null;
}
<!DOCTYPE html>
#{
Model.usr = (UsuarioWebCliente)Session["DatosUsr"];
Model.usrDrogSelec = Html.DrogSeleccionada(Model.usr);
var Lista = Html.GeneraComboDrogs2(Model.usr, Model.usrDrogSelec.cod_drogueria);
}
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>#ViewBag.Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="~/Scripts/jquery-1.9.1.js"></script>
<script src="~/Scripts/bootstrap.js"></script>
<!-- Bootstrap -->
<link href="~/Content/bootstrap/bootstrap.css" rel="stylesheet" media="screen">
</head>
<body style="height: 100%; ">
<div class="wrapper">
<div>
<div id="whitebar">
<div class="container">
<div class="row">
<div class="col-md-6">
</div>
<div class="col-md-6" style="text-align: right">
#Model.usr.DatUsrs.desc_usuario - #Model.usr.DatUsrs.codigo_ident - #Html.ActionLink("Cerrar Sesion","Logout","Account")
</div>
</div>
</div>
</div>
<div id="bluebar">
<div class="container">
<div class="row">
<div class="col-md-4">
#Html.DropDownListFor(x => x.usr.DatUsrs.cod_drogueria, new SelectList(Lista, "Value", "Text"), new { #id = "DDLMENU", data_url = Url.Action("CambiarDrog", "Menu") })
</div>
<div class="col-md-3">
Monto Consumido:
<label id="SALDO">
#(Model.usrDrogSelec.saldo_actual == 0 ? "0.00" : Convert.ToDecimal(Model.usrDrogSelec.saldo_actual).ToString("#,##.00"))
</label>
</div>
<div class="col-md-3">
Hora Corte: XXXXX
</div>
<div class="col-md-2">
Día Corte:
<label id="DIA">
#Model.usrDrogSelec.dia_corte
</label>
</div>
</div>
</div>
</div>
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img style="max-height: 20px;" src="~/Content/Images/1381797224_home.png" />
</a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
#foreach (var item in Model.MenuCollection)
{
<li class="dropdown">
#item.Name <b class="caret"></b>
#if (item.Children.Count > 0)
{
<ul class="dropdown-menu">
#foreach (var childItem in item.Children)
{
<li>#Html.ActionLink(childItem.Name, childItem.Action, childItem.Controller)</li>
}
</ul>
}
</li>
}
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<span class="glyphicon glyphicon-cog"></span><b class="caret"></b>
<ul class="dropdown-menu">
<li>#Html.ActionLink("Droguería Principal","PrioridadDrogueria","ReportesPrioridadDrogueria")</li>
<li>Mensajería </li>
<li> #Html.ActionLink("Cambio de Clave", "CambiarClave", "Account")</li>
<li>Actualizar Datos</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</nav>
<div id="Content" style="height: 100%; ">
#RenderBody()
</div>
</div>
<div class="push"></div>
</div>
<div class="footer">
<div class="row">
<div class="col-md-12 footer">Test</div>
</div>
</div>
#if (IsSectionDefined("Scripts"))
{
RenderSection("Scripts",false);
}
</body>
</html>
Did you try only
RenderSection("Scripts",false);
Instead of
#if (IsSectionDefined("Scripts"))
{
RenderSection("Scripts",false);
}
You should just call RenderSection.
#RenderSection("Scripts", false)
I got the following error while running the application I resolved it by adding #RenderSection(“Scripts”,required:false) in the _Layout page.
#RenderSection("scripts", required: false)