将变量从局部视图模型传递到父视图 - ASP.NET [英] Passing variable from partial view model to parent view - ASP.NET
本文介绍了将变量从局部视图模型传递到父视图 - ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我的部分视图只返回模型中的一个变量。但是,我需要我的javascript的变量来操作父页面中的事件,我不知道我是如何通过这个传递的?下面是我到目前为止的代码示例。
PartialView -
Hello
I have my partial view which returns only one variable from the model. However, I need the variable for my javascript to action events in the parent page and im not sure how i go about passing this through? below is examples of my code i have so far.
PartialView -
<div class="wrapper">
<div id="colour" class="center" style="background-color: blue !important;">
</div>
<h2 class="txt" style="font-weight: 500;"> @Model.cntCalls/20</h2>
<h4 class="txt">Calls made this week </h4>
</div>
来自家长视图的代码片段
Code snippet from Parent View
<h3>Lapsed and Prospect Call Report Summary</h3>
@Html.Action("StatusReview")
</div>
</div>
</div>
</div>
@section scripts{
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
@*<script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>*@
<script type="text/javascript">
window.onload = function () {
if (qty == 20) {
console.log(qty);
$('#colour').css('background', 'linear-gradient(60deg, #66bb6a, #43a047)');
$('#colour').css('box-shadow', '0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px - 5px rgba(76, 175, 80, 0.4)');
$('#phone').css('color', '#7ed682');
}
if (qty >= 15 && qty < 20) {
$('#colour').css('background', 'linear-gradient(60deg, #ffa726, #fb8c00)');
$('#colour').css('box-shadow', '0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(255, 152, 0, 0.4)');
$('#phone').css('color', '#ffc474');
}
if (qty < 15) {
$('#colour').css('background', 'linear-gradient(60deg, #ef5350, #e53935)');
$('#colour').css('box-shadow', '0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(244, 67, 54, 0.4)');
$('#phone').css('color', '#e89999');
}
}
</script>
}
有人可以帮帮我吗?
我尝试了什么:
各种网站的测试和研究
Could someone please help me ?
What I have tried:
tests and research on various sites
推荐答案
('#color')。css('background','linear-gradient(60deg,#66bb6a,#43a047)');
('#colour').css('background', 'linear-gradient(60deg, #66bb6a, #43a047)');
('#color')。css( 'box-shadow','0 4px 20px 0px rgba(0,0,0,0.14),0 7px 10px - 5px rgba(76,175,80,0.4)');
('#colour').css('box-shadow', '0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px - 5px rgba(76, 175, 80, 0.4)');
('#phone')。css('color','#7ed682');
}
if(qty> = 15&& qty< 20){
('#phone').css('color', '#7ed682'); } if (qty >= 15 && qty < 20) {
这篇关于将变量从局部视图模型传递到父视图 - ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文