I have a page where a user can update their user information (like their first name). I also have a user control on this page that displays a lot of information, including the user’s first name.
My problem I’m having is that when I change the first name on this page, the user control isn’t updated after I save the data.
Here’s my front end:
<UC:LeftNav ID="leftNav" runat="server" />
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
My button click event to save the user info:
protected void btnSave_Click(object sender, EventArgs e)
{
...
user.FirstName = txtFirstName.Text();
user.Save();
...
}
My user control that displays the user info:
protected void Page_Load(object sender, EventArgs e)
{
...
lblFirstName.Text = user.Firstname;
...
}
I went through the debugger, and I found that the btnSave_Click event on my page occurs after the Page_Load event of my user control.
Is there a way that I can get the btnSave_Click event to occur before I load the user data in my user control?
No, there is no way to change when the event is raised. But you can put your user loading code into a
Bindmethod and call it from yourbtnSave_Clickmethod.In
leftNavuser control:On page: