2014-11-14 70 views
0

我創建了一個多視圖,其中包含兩個視圖,一個用於一些信息,另一個用於發送消息。所有對第一個視圖都很好,但對於第二個視圖,消息的提交按鈕在我單擊時不會響應,並且不會觸發它的功能。
任何建議如何使其工作?

HTML:在多視圖中無法獲得文本框值

<asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="server"> 
     <ContentTemplate> 
      <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> 

      <asp:View ID="View1" runat="server"> 
      <asp:Button ID="SendPM" style="margin-left: 112px; width: 170px; height: 30px; font-size: 20px; border-radius: 15px;" runat="server" Text="Send PM" onclick="SendPM_Click"/> 

       <div style="position:relative; top: 3px; margin-left: 20px; font-size: 25px; color: black;"> 
       <i><% Response.Write(Session["ProfileEmail"].ToString()); %></i> 
       </div> 

       <br /> 
       <div style="margin-left: 35px; font-size: 20px; color: black;"> 
       <span style="font-size: 23px;">Firstname:</span> <i style="color:Green;"><% Response.Write(Session["ProfileFirstName"].ToString()); %></i> 
       <br /> 
       <span style="font-size: 23px;">Lastname:</span> <i style="color:Green;"><% Response.Write(Session["ProfileLastName"].ToString()); %></i> 
       <br /> 
       <span style="font-size: 23px;">PhoneNumber:</span> <i style="color:Green;"><% Response.Write(Session["ProfilePhoneNumber"].ToString()); %></i> 
       <br /> 
       <span style="font-size: 23px;">Age:</span> <i style="color:Green;"><% Response.Write(Session["ProfileAge"].ToString()); %></i> 
       </div> 

      </asp:View> 

      <asp:View ID="View2" runat="server"> <!-- Here is the view for the message --> 
      <asp:Button ID="GoToDetails" style="margin-left: 112px; width: 170px; height: 30px; font-size: 20px; border-radius: 15px;" runat="server" Text="Details" onclick="GoToDetails_Click"/> 
      <br /> 
      <br /> 
       <div style="margin-left: 50px;"> 
        Title: <asp:TextBox ID="TitleOfPM" runat="server" ValidationGroup="messagegroup"></asp:TextBox> 
        <br /> 
        <br /> 
        Content: 
        <asp:TextBox ID="ContentOfPM" TextMode="MultiLine" runat="server" ValidationGroup="messagegroup"></asp:TextBox> 
        <br /> 
        **<asp:Button ID="SubmitPM" runat="server" Text="Submit" onclick="SubmitPM_Click" ValidationGroup="messagegroup" />** 
       </div> 
      </asp:View> 


     </asp:MultiView> 
       </ContentTemplate> 
        </asp:UpdatePanel> 



後面的代碼:

protected void SendPM_Click(object sender, EventArgs e) 
    { 
     MultiView1.ActiveViewIndex = 1; 
    } 

    protected void GoToDetails_Click(object sender, EventArgs e) 
    { 
     MultiView1.ActiveViewIndex = 0; 
    } 

    protected void SubmitPM_Click(object sender, EventArgs e) 
    { 
     PrivateMessageInfo message = new PrivateMessageInfo(); 
     PrivateMessages u = new PrivateMessages(); 

     message.title = TitleOfPM.Text; 
     message.content = ContentOfPM.Text; 
     message.PMSender = Session["email"].ToString(); 
     message.SentTo = Session["ReplicateForEmail"].ToString(); 
     DateTime dt = DateTime.Now; 
     message.SendDate = dt.ToShortDateString(); 

     u.SendPrivateMessage(message); 
     Response.Redirect("HomePage.aspx?JobID=" + JobID); 
    } 

回答

0

您可以檢查是否在designer.cs定義按鈕文件?

+0

你是什麼意思定義? – 2014-11-15 06:04:33