- - PR -
CreateUserWizardのカスタマイズして使用する方法
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2006-10-19 10:27
どっとねっとふぁん様、
おはようございます。 アドバイスありがとうございます。 一番初めに、CreatedUserのイベント利用を思いつきましたが、 CreatedUserが呼び出された時には、まだログインした 状態ではなくて、Profile.kaiinInfoはnullになった状態で アクセスできません。 Microsoftのドキュメントによりますと、 LoginCreatedUser プロパティが true の場合、 ユーザーは CreatedUser イベントの後に Web サイトにログオンした状態になります。 とあります。 CreatedUserのタイミングでプログラムによりログインさせる 事可能なのでしょうか。 >「完了」ボタンをつかっているならFinishButtonClickイベントとかも使えると思います。 >そういったイベントの中で状態の確認ってしてみました? 完了ボタンは使用しておりません。 完了画面に、『続行』ボタンは表示されておりますが、 このボタンはすべての人が押すとは限らないので、 このボタンのイベントに処理を割り当てるのは個人的に 良くないのでは、と思います。 宜しくお願いいたします。 |
|
投稿日時: 2006-10-19 11:45
「完了」ボタンと書いたのはnewbornさんですよ。
「続行」なら押されたときにあがるイベントは変わってきますし。 記述は正確にお願いします。 ボタンが押されなくてもいいような処理にしたいならそのように書いてないと こちらには伝わりません。 > CreatedUserが呼び出された時には、まだログインした状態ではなくて、 現在試せていないのですが、CreatingUserではなくCreatedUserでもログインしてない 状態なのでしょうか? それでだめなら完了画面が表示されるときのPreRenderかなぁ。 この時点でログインしていないようなら「完了」または「継続」のボタンを 押してもらわないことにはログインできない、ってことになりますが 前にいろいろやってたときはその前にログインしてたはず。 |
|
投稿日時: 2006-10-19 12:00
ユーザの作成時にプロファイル等の情報を追加するサンプルです。
http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx タイミングとしてはCreatedUserで間違いないようです。 #サンプルあるの知ってるんだから、最初からきちんと探しとけばよかった。。。 |
|
投稿日時: 2006-10-19 19:14
どっとねっとふぁん様、
お返事が遅くなりまして、申し訳ありません。 教えていただいたリンクを元に検証作業をおこなっておりましたが、 OnCreatedUserのタイミングではログインされていないのではと思います。 頂いたリンクのページでPageDownキーを4回押した所を抜粋させていただきました。 (note that I was passing in the CreatedUserWizard1.UserName property as the username – since the user isn’t logged into the system yet※注意:ユーザーがシステムにログインしていないため、ユーザー名をCreatedUserWizard1.UserNameのプロパティーを渡しています。). この部分から察するに、OnCreatedUserより後で、ログインされるものだと思います。 なにか私の勘違いがあれば、申し訳ないです… ログインしていない状態なので、 ProfileCommon p = (ProfileCommon) ProfileCommon.Create(CreateUserWizard1.UserName, true); プロファイルを生成しそこに値を代入すればよい事がわかったので、 現在この方法での検証作業を行っております。 また結果をご報告させていただきます。 I then handled the “CreatedUser” event on the CreateUserWizard control within my CreateNewWizard.aspx.cs code-behind file to retrieve the values from the controls within the CreateUserWizard control template and set them in the profile store: // CreatedUser event is called when a new user is successfully created public void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { // Create an empty Profile for the newly created user ProfileCommon p = (ProfileCommon) ProfileCommon.Create(CreateUserWizard1.UserName, true); // Populate some Profile properties off of the create user wizard p.Country = ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Country")).SelectedValue; p.Gender = ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Gender")).SelectedValue; p.Age = Int32.Parse(((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Age")).Text); // Save profile - must be done since we explicitly created it p.Save(); } Because the user is being created as part of this step, I explicitly choose to create a new Profile object in code (note that I was passing in the CreatedUserWizard1.UserName property as the username – since the user isn’t logged into the system yet※注意:ユーザーがシステムにログインしていないため、ユーザー名をCreatedUserWizard1.UserNameのプロパティーから渡しています。). I then accessed the controls within the template of the <asp:createuserwizard> control, pulled out their values, and stuck them within the newly created profile. Calling p.save at the end registered this profile with the new username. (note: I’ll walk through how we use this profile data later in a page below). |