Reputation: 3
I have a textbox in which the user can enter their desired page title and save it. Once they save it and they happen to refresh the website, the web site title should be populated with the last title information they saved to display and the user will still have the ability to change it and re-save. I am using web forms : pls how can i get this done .Thanks
Upvotes: 0
Views: 264
Reputation: 38683
Use !ISPostBack
for see below code
protected override void OnPreInit(EventArgs e)
{
if (!IsPostBack)
{
Page.Title = YourTextBox.Text;
}
}
Upvotes: 0
Reputation: 39278
If you want the title to be persisted for all time, you have to store it in a db and dynamically set the title when the page loads. If you only need it for the remainder of the session, you may store it in session state.
I am leaving the full implementation as an exercise for the reader -- as it's too much to cover in this answer :-)
Upvotes: 1