开发者

ASP.NET 4 Profile problem

开发者 https://www.devze.com 2023-03-25 16:03 出处:网络
I hope someone can help me get over this probably simple problem. I used to use ASP and up until recently had no need to move to .NET but now I have, I\'ve realised that I\'ve missed a huge developme

I hope someone can help me get over this probably simple problem.

I used to use ASP and up until recently had no need to move to .NET but now I have, I've realised that I've missed a huge development and I'm now pretty much starting from scratch again, so please bear with me if I say something stupid.

I've managed to build a simple set of pages where new users can sign up with the basic membership details to gain access to certain pages. I now want to collect further information from them. I've built a page with a webform that shows a 开发者_开发百科list of labels and textboxes for the user to fill in and that are associated with the extra Profile elements I've added into the web.config file in the appropriate place. I'm monitoring my database through SQL Server to see what data is being collected when I enter details into the textboxes and hit the save button and that seems to be working. However, even though the page_load function runs the code to display the already collected profile info in the textboxes if they've already been filled in, nothing appears.

I've gone back to the Postal_Code example on the MSDN pages and can get the value to appear in the label when I click the button but again nothing appears if I navigate away and then return to the page.

Here's a snippet of my code, but please ask if you need anything else. I've spent hours scouring the net using a huge variety of keywords to try and find the solution to something that should be quite easy, but nobody seems to be having the same problem. Argh!

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) DisplayCurrentUserInfo() End Sub

Sub DisplayCurrentUserInfo()

    F_Name_TBox.Text = Profile.F_Name
    L_Name_TBox.Text = Profile.L_Name
    Address1_TBox.Text = Profile.Address1
    Address2_TBox.Text = Profile.Address2
    Address3_TBox.Text = Profile.Address3
    City_TBox.Text = Profile.City
    County_TBox.Text = Profile.County
    PostalCode_TBox.Text = Profile.PostalCode

Cheers, Rob


I don't know if it's solved or not, but maybe it is going to help someone else. I solved it like this:

if (!Page.IsPostBack)
{
    /*
    ... here you can assign textboxes text ...
    ... or you can call your own methods ...
    */
}

This condition is situated in Page_Load method.

0

精彩评论

暂无评论...
验证码 换一张
取 消