[英]issue calling a javascript function inside razor if statement
What i would like to do is i have 2 selector boxes set up in a view one selector holds my different profile sources. 我想做的是,我在一个视图中设置了2个选择器框,一个选择器保存着我不同的配置文件来源。 the second one holds the profile names based on the source you selected. 第二个则根据您选择的来源保存配置文件名称。
My issue is i want a certain value that is put in the database to be tested against the profile source so i pull the correct profiles based on source selected. 我的问题是我希望将某个特定的值放入数据库中,以针对配置文件源进行测试,以便我根据所选源提取正确的配置文件。
this is where I am currently with the view: 这是我目前的观点:
<div class="managerField">
<label for="Source Selector" class="label">Select Source:</label>
<select name="SourceSelector" form="PostScheduler" class="select-style" onchange="sourceSelect(this.value)">
<option value="" selected>Please Select Source</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
<div class="managerField">
<label for="ProfileSelector" class="label">Select Profile:</label>
<!-- POPULATE BASED ON SOURCE SELECTED -->
<select name="Profile Selector" class="select-style">
@foreach (var p in Model.SocialProfiles.Where(pr => pr.SocialProfileTypeID == sourceSelect(SourceSelector))
{
<option value="@p.SocialProfileID">@p.ScreenName</option>
}
</select>
</div>
@section Scripts
{
<script type="text/javascript">
function sourceSelect(el)
{
if (el == "") return 0; // Will need to catch
if (el == "1") return 2;
if (el == "2") return 6;
if (el == "3") return 15;
}
}
any help would be awesomely appreciated. 任何帮助将不胜感激。
Yuck实际上在无法在剃刀内部调用javascript的头上击中了它,我开发了一种新的单击方法,可通过JS调用它,并取消了剃刀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.