In meinem Index view.I haben eine Tabelle mit Aktionslink. In Aktion Link übergebe ich einige Argumente auf der Grundlage von Argumenten, die ich Abfrage ausführen, wenn Abfrageergebnis Null ist Ich möchte das modale in der Indexansicht anzeigen. Mein Tisch ist.modales Popup von Controller .NET MVC
@foreach(var j in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => j.job_title)</td>
<td>@Html.DisplayFor(modelItem => j.job_description)</td>
<td>@Html.DisplayFor(modelItem => j.apply_before)</td>
<td>@Html.ActionLink("Apply","applyingjobs","Student",
new {
id= @TempData["data"]
},
null
)
</td>
</tr>
}
Meine contoller Funktion, die Parameter übergeben wird empfängt.
public ActionResult applyingjobs(String id)
{
SqlConnection con = new SqlConnection("xxxxxxxxxxx");
SqlCommand cmd = new SqlCommand();
con.Open();
cmd.CommandText = "select count(*)from Users where id='" + id + "'and " + "type = " + 2 + " and exe!= null and qua!= null" ;
cmd.Connection = con;
Int32 countnamefieldadd = (Int32)cmd.ExecuteScalar();
if (countnamefieldadd == 0)
{
//here I want to show modal which is present in Index Page
}
else
{
return RedirectToAction("Index", "Student", new
{
id = id,
});
}
return RedirectToAction("Index", "Student", new
{
id = id,
});
}
Mein Modal-Code ist
<div id="modal_dialog" style="display: none">
// Modal content
</div>
Script zu nennen Modal ist
<script type="text/javascript">
$(function() {
$("#modal_dialog").dialog({
title: "Add Record",
open: function (type, data) { $(this).parent().appendTo("form"); },
modal: true
});
return false;
})
</script>
einen zusätzlichen Parameter hinzufügen und in js hinzufügen conditi Wenn der spezifische Parameterwert null ist, wird das Popup angezeigt. –
Sie können Ajax verwenden, wie [this] (https://stackoverflow.com/questions/25146683/after-success-submit-show-welcome-modal). –