.net - Asp.net Label not updated after postbck. Need extra refresh -
On the page load I'm clicking on the button after entering the record in DB, I'm checking that the user was present or Not today and display the correct label The problem is that the post label is displayed incorrectly, but if I refresh, I see the correct label.
Protects the sub-handle Btn_Click (as object, ByVal and System.EventArgs as the sender) AttendBtn handles. ConnectionString con = New SqlConnection (conString) con.Open () Dim cmd New SqlCommand ("Login in presence (UserID, Date, Presence_click) as New Connection String (" Attconnection ") as string conString = New SqlConnection Dim conString , Comments) value (@ USIDID, @date, @entendens_callic, @ comments) CMD parameter.Advate value ("@date", datetime.more) CMD parameter.Advate value ("@entensensical" GlobalVarAndFunc.CurrentCycle (2) ) cmd.Parameters.AddWithValue ("@ Comments", "") cmd.Parameters.AddWithValue ("UserID", GlobalVa rAndFunc.UserID) cmd.ExecuteNonQuery () con.Close () end sub and on page load
protected sub page_Load (Subject as sub -Visitors, as byval e.EventArgs) as the system handle S. Me.Load If GlobalVarAndFunc.Has Attended then present_LB.Text = "you already participate today" Other appearance LL.Lect = "now be present" end if Checks for the GlobalVarAndFunc.Has function if the users are currently pressed on the present button
Understand the flow of the ASP page. The system button will execute your page load before the click event. So in your case, page_load was called at that time, you will get the price at that time which is already in DB because the system has not yet executed the click event. When click event is executed, your value goes to DB (your DB was not updated before this incident). Then on the next refresh you get the right value.
Solution: Results page_load code to get results in BTN_click event at one time
Comments
Post a Comment