MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Embeded - Profile Control Example Code. HERE!  (Mono Support )

Viewed 25514 time(s), 6 post(s) 3/5/2011 12:52:39 AMby shawndg
shawndg

shawndg

3/5/2011 12:52:40 AM
Ok..

Here is a change up.. not  question.. just a example to distinguish viewing person vs profile owner..

code below..

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MonoSoftware.MonoX;
using MonoSoftware.MonoX.Utilities;
 
namespace TheScene.Web.TheScene.TestControl
{
    public partial class TestControl : MonoSoftware.MonoX.BaseAutoRegisterPart
    {
        public string PushEnter = "\r\n";
 
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void CmdGO_Click(object sender, EventArgs e)
        {
 
            //GET MY USER ID
            Guid MyGuid = SecurityUtility.GetUserId();
            string strMyGuid = ((Guid)MyGuid).ToString();
 
            //GET CURRENT VIEWED PROFILE USER ID
            Guid ProfileGuid = Guid.Empty;
            string strProfileGuid = string.Empty;
            string strProfileuserName = string.Empty;
            if (UrlParams.UserProfile.UserName.HasValue)
            {
            strProfileuserName = UrlParams.UserProfile.UserName.Value;
            ProfileGuid = SecurityUtility.GetUserId(strProfileuserName);
            strProfileGuid = ((Guid)ProfileGuid).ToString();
            }
            else
            {
            strProfileGuid = "Unknown";
            }
 
 
            TextBox1.Text = "";
            TextBox1.Text = TextBox1.Text + "YOUR UserID:" + strMyGuid + " " + PushEnter;
            TextBox1.Text = TextBox1.Text + "Profile UserName:" + strProfileuserName + " " + PushEnter;
            TextBox1.Text = TextBox1.Text + "Profile UserID:" + strProfileGuid + " " + PushEnter;
 
            if (MyGuid == ProfileGuid)
            {
                TextBox1.Text = TextBox1.Text + "YOUR PROFILE" + PushEnter;
            }
            else
            {
                TextBox1.Text = TextBox1.Text + "NOT YOUR PROFILE" + PushEnter;
            }
 
 
 
        }
 
    }
}
This content has not been rated yet. 
1871 Reputation 252 Total posts
khorvat

khorvat

3/5/2011 9:45:40 AM
Hi,

thanks for the sample code.

I need to mention that this is one way to find out what is the profile owner user but it is not necessarily for this code to work in every scenario. This code will work in scenario when UserProfileModule is placed on the MonoX User profile page which is just a demo page. Let's say you place a UserProfileModule on some other page and turn off "AutoUserDetect" feature, and you are setting programmatically "UserId" on UserProfileModule then you will end up with situation that you don't have a username in the Url. In that scenario, for the embedded user profile sub modules, it is best to use the "UserId" property and that way you will be sure that "UserId" is the valid user profile owner.

I hope this clears things a bit more for you and that you will implement your embedded profile module in a best way.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
shawndg

shawndg

3/5/2011 11:48:19 AM
Yes it does makes sense..

It actually brings me to think more a long the lines of what needs done..

And Im not sure the best way a accomplish this with Monox..

Here is my issue.

My site has a need for guest/users with profile/ users with out profiles..

lets just say.. guest - have no profiles.. they can just view stuff.. prob not much work here..
now lets say.. user signs up.. and then somehow I assign a type... A,B, or C

A - Normal User - no profile
B - User type B - Profile Type B
C - User type C - Profile Type C

How is the best way about doing this ?
This content has not been rated yet. 
1871 Reputation 252 Total posts
denis

denis

3/5/2011 3:00:34 PM
That's a standard scenario - for example, job portals usually have two type of users, job seekers and employers, each with quite different profile attributes.
We generally don't use the ASP.NET profile infrastructure for more complex cases, but the choice is yours. When ASP.NET profiles are used, all the user data is serialized to the single DB field, which makes it easy to change the profile structure - however, you give up the possibility to easily search and manipulate profile data via SQL queries.
When a higher degree of control is needed we usually create a single custom profile database table with 1:1 relationship to the users table and manually develop a profile GUI - MonoX profile templates can still be used, as described here http://www.mono-software.com/blog/post/Mono/38/Support-for-ASP-NET-profiles-in-MonoX/ 

Let me know if you plan to stick with the standard ASP.NET profiles, or if you plan to use a custom solution.
 
This content has not been rated yet. 
7207 Reputation 956 Total posts
shawndg

shawndg

3/5/2011 4:26:52 PM
I like the idea of a custom solution..

I want the ability to run SQL against profile fields..

Now with this said.. how would I go about creating a custom profile solution..

I'm trying to create.. more then one profile type.. and yes each profile will contain different information and what kind of a profile a user has will be dependent on the users type..
This content has not been rated yet. 
1871 Reputation 252 Total posts
khorvat

khorvat

3/7/2011 4:11:26 PM
Hi,

I'll try to provide you with sample code here (your other post related to this topic).
This content has not been rated yet. 
15993 Reputation 2214 Total posts