This question may be repeated, but I have a problem. I have a drop-down list and a search button on my page. where I associate the view with the model in the dropdown list of the change event. And when you click on the value of the "Search" button, the one selected in the drop-down list related to the list of records is displayed on the partial image. This is all done correctly, as below:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ApricaCRMEvent.Models.CRM.DatabaseEntities.CRM_Doctor_Request>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
MDLNoDDLIndex
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script src="../../Scripts/jquery.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-migrate-1.0.0.js" type="text/javascript"></script>
<script type="text/javascript">
$("#viewlist").hide();
function TestFun()
{
var mdlno = $("#ddlMDLNo").val();
var txtmdlno = document.getElementById("Request_For_Id");
txtmdlno.value = mdlno;
$("#viewlist").hide();
}
var mdlno = $("#ddlMDLNo").val();
function Datalist(mdlno) {
$("#viewlist").show();
$.ajax({
url: "/Search/MDLNoDataList",
type: "POST",
data: mdlno,
dataType: "html",
success: function (data) {
$("#viewlist").html(data);
},
error: function () {
alert("No Projects Found");
$("#viewlist").html('there is error while submit');
}
});
}
</script>
<div>
<h2>Search by MDLNo</h2>
<% using (Html.BeginForm())
{ %>
<%: Html.ValidationSummary(true, "Profile Updation was unsuccessful. Please correct the errors and try again.") %>
Select MDLno
<%= Html.DropDownList("ddlMDLNo", ViewData["MDLno"] as SelectList, "--Select One--", new { onchange = "TestFun()" })%>
<%: Html.HiddenFor(model => model.Request_For_Id) %>
<input type="submit" value="search" name="SearchMDLNo" id="btnclick" onclick ="Datalist(a)"/>
<div id="viewlist"><%Html.RenderAction("MDLNoDataList"); %> </div> <%--partial view should be loaded here.--%>
<% } %>
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>


Everything works correctly, but .. a partial view of the div tag is displayed before the search button is clicked. I want this ... Loading a partial image when I press a button
for this i tried this code:
$("#btnclick").click(function () { $("#viewlist").load('/Search/MDLNoDataList.ascx') });
.show() .hide(), - , , , .
:
public ActionResult MDLNoDDLIndex()
{
ViewData["MDLno"] = new SelectList(CRMSearchReportDL.getAllMDLno(), "Request_For_Id", "Request_For_Id");
return View();
}
[HttpPost]
public ActionResult MDLNoDDLIndex(CRM_Doctor_Request model)
{
ViewData["MDLno"] = new SelectList(CRMSearchReportDL.getAllMDLno(), "Request_For_Id", "Request_For_Id");
return View();
}
public ActionResult MDLNoDataList()
{
List<CRM_Doctor_Request> drlist = new List<CRM_Doctor_Request>();
return PartialView(drlist);
}
[HttpPost]
public ActionResult MDLNoDataList(CRM_Doctor_Request model)
{
return PartialView(CRMSearchReportDL.getMDLNoWiseDetails(model.Request_For_Id));
}