在Multiview中无法获取文本框值

时间:2014-11-14 21:35:39

标签: c# html asp.net

我创建了一个多视图,里面有两个视图,一个用于显示某些信息,另一个用于发送消息。所有这些都适用于第一个视图,但对于第二个视图,消息的提交按钮在我点击它时不会响应,并且不会激活它的功能。
有什么建议如何使其工作?

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);
    }

1 个答案:

答案 0 :(得分:0)

你能检查一下在designer.cs文件中是否定义了按钮?