开发者

Modal popup not generating postback to page

<ajaxToolkit:ModalPopupExtender  runat="server" 
         id="ModalPopupExtender1"
         cancelcontrolid="btnCancel" okcontrolid="btnOkay" 
         targetcontrolid="Button1" popupcontrolid="Panel1" 
         drag="true" 
         backgroundcssclass="ModalPopupBG"
        />

<asp:Button ID="Button1" runat="server" Text="Test Modal Popup" 
    onclick="Button1_Click" />
    <br />

<asp:UpdatePanel ID="up" runat="server">
    <ContentTemplate>
        <asp:Button ID="Button2" runat="server" Text="Post Back" 
        onclick="Button2_Click" />
        <asp:Label ID="Label1" runat="server" AutoPostBack="true" Text="Nothing has happened yet..."></asp:Label>

        <asp:Panel ID="Panel1" runat="server" AutoPostBack="true">
            <div class="HellowWorldPopup">
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:Button ID="btnCancel" runat="server" Text="Canel" 
                    onclick="btnCancel_Click" />
                <asp:Button ID="btnOkay" runat="server" Text="Okay" onclick="btnOkay_Click" />
            </div>
        </asp:Panel>

    </ContentTemplate>
</asp:UpdatePanel>

So I am trying to get the Label to have the contents of what the user typed in the textbox inside the modal popup. Right now the btnOkay is not causing this to work.

.cs开发者_运维知识库 file:

protected void btnCancel_Click(object sender, EventArgs e)
{
    TextBox1.Text = "";
}
protected void btnOkay_Click(object sender, EventArgs e)
{
    Label1.Text = TextBox1.Text;
    TextBox1.AutoPostBack = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
    Label1.Text = "";
    TextBox1.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{
    Label1.Text = "You clicked the button";
}

I do not want the page to post back at all, but just to update the hidden labels on the page once information is entered. How do I do this?


Edit: Alright, this should do the trick I think.

<ajax:ModalPopupExtender runat="server" id="ModalPopupExtender1" targetcontrolid="Button1"
    popupcontrolid="Panel1" drag="true" backgroundcssclass="ModalPopupBG"  />
<asp:Button ID="Button1" runat="server" Text="Test Modal Popup" /><br />
<asp:Panel ID="Panel1" runat="server">
    <div class="HellowWorldPopup">
        <asp:TextBox ID="TextBox1" runat="server" />
        <asp:Button ID="btnCancel" runat="server" Text="Canel" onclick="btnCancel_Click" />
        <asp:Button ID="btnOkay" runat="server" Text="Okay" onclick="btnOkay_Click" />
    </div>
</asp:Panel>

<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Nothing has happened yet..." />
    </ContentTemplate>
</asp:UpdatePanel>

.

protected void btnCancel_Click(object sender, EventArgs e)
{
    TextBox1.Text = ""; 
}

protected void btnOkay_Click(object sender, EventArgs e)
{
    Label1.Text = TextBox1.Text;
    up.Update();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜