2016-12-22 53 views
0

我有一個帶有文本字段的表單以允許用戶搜索MRN。如果MRN存在,他們可以添加新的相遇。如果MRN不存在,他們可以添加一個新的患者。如果他們在模式選擇「是」如果引導值爲yes,則將值從一種表單傳遞給另一種表單asp.net

if (searchresult != null) 
     { 
      lblModalTitle.Text = "This MRN exists!"; 
      lblModalBody.Text = "Would you like to add a new encounter for this patient?"; 
      ScriptManager.RegisterStartupScript(Page, Page.GetType(), "EncounterModal", "$('#EncounterModal').modal();", true); 
      upEncModal.Update(); 
     return; 
     } 
     else 
     { 
      PatModalTitle.Text = "This MRN does not exist!"; 
      PatModalBody.Text = "Would you like to add a new patient to the database?"; 
      ScriptManager.RegisterStartupScript(Page, Page.GetType(), "PatientModal", "$('#PatientModal').modal();", true); 
      upPatModal.Update(); 

     } 

,我想從搜索與MRN來填充NewPatient或NewEncounters頁面MRN文本框:當他們點擊搜索按鈕,它會彈出這個模式頁。這是我的模態的代碼是什麼樣子:

<div class="modal fade" id="PatientModal" role="dialog" aria-labelledby="PatientModalLabel" aria-hidden="true"> 
     <div class="modal-dialog"> 
      <asp:UpdatePanel ID="upPatModal" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional"> 
      <ContentTemplate> 
      <div class="modal-content"> 
       <div class="modal-header"> 
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
        <h4 class="modal-title"><asp:Label ID="PatModalTitle" runat="server" Text=""></asp:Label></h4> 
       </div> 
       <div class="modal-body"> 
        <asp:Label ID="PatModalBody" runat="server" Text=""></asp:Label> 
       </div> 
       <div class="modal-footer"> 
        <asp:LinkButton ID="NewPatientBtn" runat="server" CssClass="btn btn-primary" data-dismiss="modal" aria-hidden="true" value="send" OnClientClick="window.location.href='NewPatient.aspx;">Yes</asp:LinkButton> 

        <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">No</button> 
       </div> 
      </div> 
      </ContentTemplate> 
      </asp:UpdatePanel> 
     </div> 
    </div> 

的所有方法我試過旁路模態和加載下一頁,或者他們根本不工作。我只需要一個基本的修補程序,因爲它適用於內部Web表單應用程序。

protected void SearchMRN_Click(object sender, EventArgs e) 
{ 
Session["mrn"] = SearchMRN.Text; 
Server.Transfer("NewPatients.aspx"); 
} 

在目標頁面而這個::現在我在源頁面使用這個

void Page_Load(object sender, EventArgs e) 
{ 
PAT_MRN.Text = Session["mrn"].ToString(); 
Session.Remove("mrn"); 
} 

模態彈出,但我不斷收到一個「JS1015:未終止的字符串常量」錯誤,並且它不會加載下一頁。請幫忙!我非常感激。提前致謝。

回答

0

我找到了解決方案。這對我來說很有用。

在我SearchMRN_Click類執行搜索後,我做的:

HttpCookie C = new HttpCookie("MRN"); 
    C.Value = SEARCH_MRN.Text; 
    Response.Cookies.Add(C); 

而且在NewPatients.aspx(目標頁)

 if(Request.Cookies["MRN"] != null) 
    { PAT_MRN.Text = Request.Cookies["MRN"].Value; } 

無需一個Response.Redirect因爲模式會彈出並在提示用戶選擇後進行重定向。

相關問題