Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 10, 2008 07:00 AM by JohanKi
Jan 10, 2008 06:49 AM|LINK
Hi, it's me, again.
I'm making a site that users will log into and I thought that saving a few extra tidbits that they can enter would be swell - so I made a "settings page" with three text-boxes and a button saying "save settings". These settings are to be stored using profiles
since it's not a lot of information and .. well.. the profile system is there allready.
However, when I press the button, the page reloads, but the information typed into the boxes are reverted to the old information in the profile and doesnt update it (or perhaps rather, the information typed into the boxes arn't sent to the server), I know
the profile is updated though because I can see the time-stamp in the Profile.LastUpdatedDate - attribute. So the natural question is "why is this so? Why isnt the data sent to the server?"
My settings page is placed in a nested contentplaceholder (ie. the settings page has a masterpage "menu" and my masterpage "menu" has a masterpage "base" (I dont know if this matters so I metnion it)) and in the base-masterpage there is the
with the event handler:
Profile.field1 = TextBox1.Text.ToString();
Where should I look to overcome this problem. Im sure there's something.. stupidly simple I have just not put in there but I dont know what :|
Jan 10, 2008 06:53 AM|LINK
Have you, by any chance, code in a Page Load event handler that sets the value of the text boxes to that stored in the profile? If you have, you need to consider protecting that code so that it is only executed if a postback is not occurring, i.e.
if( !IsPostback )
// Set text box values from the profile
Jan 10, 2008 07:00 AM|LINK
Dave, you are my hero :)
Ah the old "!isPostback"-nemesis. That was Exactly what I had done and now that I think about it, page_load is probably run before my button event handler huh, heh, so no wonder it wrote the information over.
Thanks again Dave for the (extremely haste post haste) reply.