Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

updatePanel does not send button click event back to server

$
0
0

Hello,

I  have a sample page that has a label for message, and a text box to be populated by the 2nd textbox content. The 2nd textbox is where use can paste/edit content; a button that will perform some task. Whenever the 2nd textbox is changed, I want the label and the 1st textbox to update itself according to the content in 2nd textbox. I have the label and 1st textbox in an UpdatePanel, and to be updated by the 2nd textbox' textChanged event.

The problem is if I make change in the 2nd text box, then click the button. It seems the panel gets updated correctly, but the button's onClick event does not fire.

for example, I put some 'abcd' in 2nd textbox, and click the button: the query name is updated to 't', and label to 'abcd'; I add '123' into 2nd textbox: the query name is updated to 'ttb' and label to 'abcd 123'. subsequent click of button make the 1st textbox updated to 'ttb tb tb' etc.

Here is the ASP code:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="updatepanel._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
 <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
   <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
    </p>
    <p>
        You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
            title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
    </p>
   
            <p>&nbsp;</p>

                                 <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                                <ContentTemplate>
      <asp:Panel runat="server" ID="pnlSystemMessages">
                <asp:Label runat="server" ID="lblSystemMessages" CssClass="warnings"></asp:Label>
                <asp:ValidationSummary ID="vldSystemMessages" DisplayMode="BulletList" CssClass="systemMessages"
                    runat="server" ValidationGroup="Login1" />
                <asp:Label runat="server" ID="lblSuccessMessages" CssClass="success"></asp:Label>
           
            <p>&nbsp;</p>
                                              <b>Query Name</b>&nbsp;&nbsp;<asp:TextBox ID="txtQuery" runat="server" Height="200px" ToolTip="Enter a name for query" Width="590px" MaxLength="80" TextMode="MultiLine"> </asp:TextBox>
                                    &nbsp;&nbsp;<b>(optional)</b>

                                     </asp:Panel>
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="txtSequence" EventName="TextChanged" />
                                </Triggers>
                            </asp:UpdatePanel>
                            <p></p>
                            <asp:TextBox ID="txtSequence" runat="server" AutoPostBack="true"
                                    ontextchanged="txtSequence_TextChanged" Rows="10" TextMode="MultiLine"
                                    Width="590px"></asp:TextBox>
                                    <p></p>
                                    <asp:Button ID="btn" runat="server" Font-Bold="true" Height="25px"
                                    OnClick="btn_Click" Text="BLAST" />
</asp:Content>

C# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace updatepanel
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void txtSequence_TextChanged(object o, EventArgs arg)
        {
            //txtQuery.Text = txtSequence.Text.Substring(1, 25);
            lblSystemMessages.Text = txtSequence.Text;
            txtQuery.Text += "t";
        }

        protected void btn_Click(object sender, EventArgs e)
        {
            txtQuery.Text += "b ";
        }
    }
}

Thanks!!!


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>