i'm getting started mvc, can't seem manipulate view controller if i'm not using...
public actionresult index() { return view(); } when use function not index() attempt update, seems if page not changing @ all. in fact, seems page steps of expected controller , partial view calls, loads default page anyway. think i'm doing wrong in how i'm communicating view.
here current process:
created view controls. want user enter search data, click search button, , begin query retrieve results. results displayed in web grid once retrieved.
<div class="searchonewrp"> <fieldset> <legend><strong>patient 1 search</strong></legend> first name: <input type="text" id="fnamepone" /> last name: <input type="text" id="lnamepone" /> d.o.b.: <input type="text" id="dobpone" /> <button class="patient_look_up_button" id="btnponesearch" name="btnponesearch" type="submit" onclick="patientonesearch()" title="search"> search </button> </fieldset> @if (model != null && model.count() > 0) { html.renderpartial("patientonesearch"); } </div> my model:
namespace mynamespace.repository.model { public class patientmerge { public int pat_id { get; set; } public string pag_status_cn { get; set; } public string fname { get; set; } public string lname { get; set; } public string birth_date { get; set; } public string ageyears { get; set; } public string gender_cd { get; set; } public string phone_no { get; set; } public string addr1 { get; set; } public string addr2 { get; set; } public string city { get; set; } public string state_cd { get; set; } } } my ajax gets controller query:
public partialviewresult getpatientonesearch(string fname, string lname, string dob) { try { var target = new patientrepository(); var result = target.getpatient(fname, lname, dob, "", "", ""); list<mynamespace.repository.model.patientmerge> patientlist = new list<mynamespace.repository.model.patientmerge>(); (int = 0; < result.count; i++) { mynamespace.repository.model.patientmerge patient = new mynamespace.repository.model.patientmerge(); patient.pat_id = result[i].patientid; patient.fname = result[i].firstname; patient.lname = result[i].lastname; patient.birth_date = result[i].dateofbirth.tostring(); patientlist.add(patient); } return partialview("patientonesearch", patientlist); } catch (exception ex) { logger.log.error(ex.message + ex.stacktrace + ex.innerexception); //return json(new { error = ex.message }, jsonrequestbehavior.allowget); return partialview("patientonesearch", null); } } which goes partial view...
@model ienumerable<mynamespace.repository.model.patientmerge> <div id="grdpatientonesearch"> @if (model != null && model.count() > 0) { var grid = new webgrid(model); grid.gethtml(tablestyle: "webgrid", headerstyle: "header", alternatingrowstyle: "alt", selectedrowstyle: "select", columns: grid.columns( grid.column("pat_id", "id"), grid.column("fname", "first name"), grid.column("lname", "last name"), grid.column("birth_date", "dob") ) ); } else { <label>no records found.</label> } aaaaaand nothing displays on in browser. in fact, testing i've done, swear returns default view. not hit return view(); above, testing i've attempted in last 2 days, swear has happening.
am doing wrong in how i'm updating view?
i'm going make second answer 1 why not set html
<div class="searchonewrp"> <fieldset> <legend><strong>patient 1 search</strong></legend> first name: <input type="text" id="fnamepone" /> last name: <input type="text" id="lnamepone" /> d.o.b.: <input type="text" id="dobpone" /> <button class="patient_look_up_button" id="btnponesearch" name="btnponesearch" type="submit" onclick="patientonesearch()" title="search"> search </button> </fieldset> @if (model != null && model.count() > 0) { <div id="patientsearchpartial"> </div> } </div> then in js code
getajax('patientmerge/getpatientonesearch', 'json', { 'fname': fname, 'lname': lname, 'dob': dob }, function (data) { $('#patientsearchpartial').html(data); } ) because partial view action result returns html why not use jquery fill div html returned hit partial view , refill html data controller
Comments
Post a Comment