Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Textbox value in Update panel

Textbox value in Update panel

Scheduled Pinned Locked Moved ASP.NET
htmlvisual-studiosysadminalgorithmstutorial
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Girish481
    wrote on last edited by
    #1

    Hello, I am using VS 2005

    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager id="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel id="UpdatePanel1" runat="server" EnableViewState="False">
    <contenttemplate>
    <asp:TextBox ID="TextBox1" runat="server" Style="position: relative; top: 0px;"></asp:TextBox><br />
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Style="position: relative"
    Text="Next" />
    <asp:Button ID="Button2" runat="server" Style="position: relative" Text="Pevious" OnClick="Button2_Click" />
    <asp:Button ID="Button3" runat="server" Style="left: 0px; position: relative" Text="Update" OnClick="Button3_Click" /><br />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand='SELECT * FROM "EMP"'>
    </asp:SqlDataSource>
    </contenttemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Button3" EventName="Click" />
    </Triggers>
    </asp:UpdatePanel>
    </div>
    </form>
    </body>
    </html>

    And in the aspx.vb file i have code following: Protected Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click MessageBox.Show(TextBox1.Text, "xx", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) End Sub but it is not showing me the current value (user chaged the value; when page comes on the browser) of the textbox; it is showing me the value which was at the time of page load. After searching a lot on the net, i am posting the question here, to get the solution how to get the current/changed value of the textbox which is in the update panel; on click of the button. Thanks & Regards Girish Sharma

    P 1 Reply Last reply
    0
    • G Girish481

      Hello, I am using VS 2005

      <head runat="server">
      <title>Untitled Page</title>
      </head>
      <body>
      <form id="form1" runat="server">
      <div>
      <asp:ScriptManager id="ScriptManager1" runat="server">
      </asp:ScriptManager>
      <asp:UpdatePanel id="UpdatePanel1" runat="server" EnableViewState="False">
      <contenttemplate>
      <asp:TextBox ID="TextBox1" runat="server" Style="position: relative; top: 0px;"></asp:TextBox><br />
      <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Style="position: relative"
      Text="Next" />
      <asp:Button ID="Button2" runat="server" Style="position: relative" Text="Pevious" OnClick="Button2_Click" />
      <asp:Button ID="Button3" runat="server" Style="left: 0px; position: relative" Text="Update" OnClick="Button3_Click" /><br />
      <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand='SELECT * FROM "EMP"'>
      </asp:SqlDataSource>
      </contenttemplate>
      <Triggers>
      <asp:AsyncPostBackTrigger ControlID="Button3" EventName="Click" />
      </Triggers>
      </asp:UpdatePanel>
      </div>
      </form>
      </body>
      </html>

      And in the aspx.vb file i have code following: Protected Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click MessageBox.Show(TextBox1.Text, "xx", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) End Sub but it is not showing me the current value (user chaged the value; when page comes on the browser) of the textbox; it is showing me the value which was at the time of page load. After searching a lot on the net, i am posting the question here, to get the solution how to get the current/changed value of the textbox which is in the update panel; on click of the button. Thanks & Regards Girish Sharma

      P Offline
      P Offline
      padmanabhan N
      wrote on last edited by
      #2

      plz check whether you have checked the page load in your page load event.... code in c#: if (!IsPostBack) { //Code }

      Padmanabhan

      G 1 Reply Last reply
      0
      • P padmanabhan N

        plz check whether you have checked the page load in your page load event.... code in c#: if (!IsPostBack) { //Code }

        Padmanabhan

        G Offline
        G Offline
        Girish481
        wrote on last edited by
        #3

        in the page load event i have following code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Page.IsPostBack = False Then Session("r") = 0 End If 'dv.Table.Rows(1)(1) = "xx" showdata() End Sub Regards Girish Sharma

        P 1 Reply Last reply
        0
        • G Girish481

          in the page load event i have following code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Page.IsPostBack = False Then Session("r") = 0 End If 'dv.Table.Rows(1)(1) = "xx" showdata() End Sub Regards Girish Sharma

          P Offline
          P Offline
          padmanabhan N
          wrote on last edited by
          #4

          try to put the showdata() inside the post back. that is the error... code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Page.IsPostBack = False Then Session("r") = 0 'dv.Table.Rows(1)(1) = "xx" showdata() End If End Sub

          Padmanabhan

          G 1 Reply Last reply
          0
          • P padmanabhan N

            try to put the showdata() inside the post back. that is the error... code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Page.IsPostBack = False Then Session("r") = 0 'dv.Table.Rows(1)(1) = "xx" showdata() End If End Sub

            Padmanabhan

            G Offline
            G Offline
            Girish481
            wrote on last edited by
            #5

            Thanks a lot padmanabhan N. It is working fine; but it is really new to me how it is working now; when page's postback event has been fired and i have following in showdata: Public Sub showdata() dv = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), System.Data.DataView) TextBox1.Text = dv.Table.Rows(Session("r"))(1).ToString() End Sub what is the relation with the postback's true/false? I wish to thanks for providing the the answer and shall be more informative for the question i asked above please. Best Regards Girish Sharma

            P 1 Reply Last reply
            0
            • G Girish481

              Thanks a lot padmanabhan N. It is working fine; but it is really new to me how it is working now; when page's postback event has been fired and i have following in showdata: Public Sub showdata() dv = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), System.Data.DataView) TextBox1.Text = dv.Table.Rows(Session("r"))(1).ToString() End Sub what is the relation with the postback's true/false? I wish to thanks for providing the the answer and shall be more informative for the question i asked above please. Best Regards Girish Sharma

              P Offline
              P Offline
              padmanabhan N
              wrote on last edited by
              #6

              with pleasure, The postback is doing all the things. The loop your write inside the postback will fire only when the page is loaded and the value will be maintained and the loop wont be executed after that. So, if we write the code after the loop will be fired in even and every postback. just keep the breakpoint in the page load and check. You can see for each and every postback the pageload event is fired. So each and every time the button click it fires the page load first and then the button event. So, the showdata() will clears your modification and the original data will be set. For this only you got the old values. I hope you understand now.

              Padmanabhan

              G 1 Reply Last reply
              0
              • P padmanabhan N

                with pleasure, The postback is doing all the things. The loop your write inside the postback will fire only when the page is loaded and the value will be maintained and the loop wont be executed after that. So, if we write the code after the loop will be fired in even and every postback. just keep the breakpoint in the page load and check. You can see for each and every postback the pageload event is fired. So each and every time the button click it fires the page load first and then the button event. So, the showdata() will clears your modification and the original data will be set. For this only you got the old values. I hope you understand now.

                Padmanabhan

                G Offline
                G Offline
                Girish481
                wrote on last edited by
                #7

                padmanabhan N Thank you so much for clearing doubts and nice explanation. Best Regards Girish Sharma

                P 1 Reply Last reply
                0
                • G Girish481

                  padmanabhan N Thank you so much for clearing doubts and nice explanation. Best Regards Girish Sharma

                  P Offline
                  P Offline
                  padmanabhan N
                  wrote on last edited by
                  #8

                  its ok, Happy coding..

                  Padmanabhan

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups