1

I have this code in form:

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:TextBox ID="Text1" runat="server"></asp:TextBox>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:TextBox ID="Text2" runat="server"></asp:TextBox>
            <asp:Button ID="Submit" runat="server" OnClick="Submit_Click"
                Text="Click Me"/>
        </ContentTemplate>

    </asp:UpdatePanel>

When I click on Submit button, the all form is posted back on server (Text1 and Text2). I want to post back only textbox in UpdatePanel (Text2). Is it possible?

Thank you for responses.

EDIT (Solution): I think, I have solution using Javascript:

    function onSubmit() {
        var text1 = this.document.getElementById('<%=Text1.ClientID%>');
        text1.disabled = true;
        return true;
    }

    ....

    <asp:Button ID="Submit" OnClientClick="onSubmit();" ..../>

It cause that Text1 will be disabled before PostBack. It seams that ASP.NET do not post back values from disabled textboxes. Hovewer, this works only without UpdatePanel. Of course, Text1 is empty after postback.

polach.o
  • 652
  • 8
  • 16

1 Answers1

-1

Well, the UpdatePanel controls what get's posted back. You cannot change that behavior. It should be posting the form data for the UpdatePanel only (I believe), plus the entire ViewState. It has to post the entire ViewState for the page lifecycle to work.

Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • Submit button posted back Text2 (what I want to), but also Text1 (which isn't in UpdatePanel). If I set property _EnableViewState_ to false on Text1, it still posted back on submit. – polach.o Feb 28 '13 at 13:35
  • This answer explains that all form data is submitted all the time: https://stackoverflow.com/a/8326714/6305294 – Alex Aug 13 '19 at 02:42