.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

get user property

Posted By:      Posted Date: October 01, 2010    Points: 0   Category :ASP.Net

I am using .net membership. i got my login page where i want to get the avatar(property) of the current login user and save in a cookie but dont know how can i achieve that? any ideas?

  Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogin.Click

        Dim authenticate As Boolean

        authenticate = Membership.ValidateUser(txtUsername.Text, txtPassword.Text)

        If authenticate Then
            ' AvatarCookie

            Dim AvatarCookie As New HttpCookie("AvatarImage")
            AvatarCookie("value") = "" '  ???
            AvatarCookie.Expires = DateTime.Now.AddDays(7)
            ' Avatar cookie ends here

            'Create Cookie or Delete Cookie
            If chkPersistCookie.Checked = True Then
                'Create Cookie
                Dim myCookie As New HttpCookie("chkPersistCookie")
                myCookie("value") = txtUsername.Text
                myCookie.Expires = DateTime.Now.AddDays(7)
                'Delete Cookie
                If Request.Cookies("chkPersistCookie") IsNot Nothing Then
                    Dim myCookie As New HttpCookie("chkPersistCo

View Complete Post

More Related Resource Links

Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

User Control and DataSourceID Property


I created a user control (.ascx) that contains a paging-user-control, a repeater and some other controls.
I want to use the property DataSourceID. How should I get the data from the datasource and when?
What is the recommended way?

I did it this way:
- Create a method to get the data by reflection, like:

private void PerformSelect()
	if (!String.IsNullOrEmpty(this.DataSourceID))
		Control control = Page.FindControl(this.DataSourceID);
		if (control == null)
			control = Parent.FindControl(this.DataSourceID);

		MethodInfo method = control.GetType().GetMethod("Select");
		IEnumerable data = (IEnumerable)method.Invoke(control, new object[0]);

		this.DataSource = data;
 - Call this method
In PageLoad when no postback
Changing the current page (paging-user-control)
Changing the current tab (tab-user-control)
Switching Visibility to true

I think that way is not the optimum, is there any better way?
Do you have any suggestions or links?

Thanks for your help, Andreas

User Control as Composite Control Property


I have a composite control (Called Dialog) which has a property "ContentControl"

At design time, I'd like this property to bind to a user control that is on the page.

When I add the items in the designer, the designer loads as expected.

However, when I try to run the web page, I get the following error:

Parser Error Message: Cannot create an object of type 'System.Web.UI.UserControl' from its string representation 'EditTerm1' for the 'ContentControl' property.

Please let me know if there is another way to bind a user control as a property of a composite control.


Designer Code:


	<cc1:Dialog ID="Dialog1" runat="server" Buttons="SaveCancel" 
Title="Edit Term" ContentControl="EditTerm1" />

Unable to search Custom User Property Created in User Profiles in SharePoint 2010


Hi ,

I have created a custom user property,and created metadata property and added mapping to it, still i m not able to Search in People,Please advise

Dynamic Binding of a Public Property in a User Control

Hi, I am not sure how to pass a variable from an .aspx page to an .ascx page.  I have a Control that puts rotating banners on a page.  The control has several public properties.  However, only one of those properties changes on the page level.  All the other properties are the same for every page site-wide.  So, instead of setting all the properties on every page in my sites (many sites), I want to set it up so I only have to setup the sitewide properties once and only the page level properties on each page.   I want to create a control with a property of AdKeyword="somename" and pass it to another control that will grab that page-level property and add it to all the other site-wide properties.  I guess what I need could be called a Dynamic Control Property.   My .aspx page has:<%@ Register TagPrefix="uc1" TagName="Banner1" Src="banner1.ascx" %> <asp:Content ID="Leaderboard" runat="server" ContentPlaceHolderID="Leaderboard"> <uc1:Banner1 AdKeyword="L2Chamber" runat="server" OverrideHeight="90" /> </asp:Content> My banner1.ascx page has:<%@ Control Language="VB" ClassName="UserControl297" %> <%@ register tagprefix="uc1&

How can I get a user list based on a specific profile property.

Hi,I am trying to query a DB and get a list of users based on a specific boolean property stored in the aspnet_profile for that user.I am aware that it wasn't possible a few years ago (http://forums.asp.net/p/988051/1277359.aspx), but was wondering whether that had changed in recent releases, or it was still not possible without trawling through the entire list of users and testing them one by one.  (My DB may become way to big for that.)Thanks in advance for any help.Regards,Ben

Accessing a public property of a nested user control in a master page from a pages' user control

Hi  I've got a web site that has a master page and that master page (mpMaster that has a user control (ucControl1) which has a sub user control (ucControl2), this user control has a property which accepts a value. Now, I have a page that uses the master page and on this page I have another user control (ucPageControl), I need to  find a way of setting the value in ucControl2 from ucPageControl. Is this possible at all? Many thanks Ed

Add property to user control design time properties VB windows forms

hi  everyBody,   I've  created a user control that exports a given radGridView to many file formats like Excel, PDF, Csv,... this user control takes the Gridview object as aprobeity Public Class ucExport Private _grdName As RadGridView Private exporter As RadGridViewExcelExporter Private exportVisualSettings As Boolean Dim fileName As String Dim openExportFile As Boolean Public Property grdObj As RadGridView Set(ByVal value As RadGridView) _grdName = value End Set Get Return _grdName End Get End Property End class  how could I add this property to design mode, that's when I click F4, how can I add this to prosperities, rather than code mode  

User Profile Property creation


I have inadvertently deleted the user profile property SPS-PhoneticDisplayName which means that users now get an error when trying to view their profile as the page tries to use this field. With cutom errors turned off in the web config file the message states  that the property must be created by an administrator using the profile administration tool.

When I try to re-create the property I get the following error Invalid Property name. Please enter a property name that matches the specification of URI schema name (RFC2396), which must begin with a letter, and must contain only letters, digits, and the characters ".", "+", or "-".

The property name appears to meet these requirements but it still fails. (if I remove the '-' from the name the property is created)

anyone know how I can recover the SPS-PhoneticDisplayName property?

Problem with property editor of a web user control



I created an asp.net user control with a property named 'TabList' , the property is visible when I place my control on a page, the default editor for this property was a simple text box, but I needed a DropDownList for editing the TabList property of my control, so I added following code to implement it:

<Category("Navigation Bar"), Editor(GetType(DropDownList), GetType(System.Drawing.Design.UITypeEditor)), Description("List of Tabs"), DefaultValue("SHISHIR WAHI")> Public Property TabList() As String
            Return _tablist
        End Get

        Set(ByVal value As String)
            _tablist = value
        End Set
    End Property

The Category() and DefaultValue() are working fine but Editor() and Description() are not, what could be the problem?

Please help.

Add User Profile Property -- missing AD attribute


I am trying to add a user profile property, when I tried to map this field to a AD attribute, I realized not all the attributes are exposed. Is there anything I might be missing in SP, or something I have to setup in AD?

Please advice, your help would be greatly appreciated.

Passing a user defined type property to WCF contract



i have a class with a user defined type as follow.

[DataContract(Namespace = "a.com")]
  public class Order : IOrderDescription, INotifyPropertyChanged
    public static OrderLimitations OrderLimits { get; set; }
    public OrderLimitations ThisOrderLimits { get; set; }
    public OrderAlgorithmDescription AlgoDescription { get; set; }

 [DataContract(Namespace = "a.com")]
  public class OrderAlgorithmDescription
    public OrderAlgorithmName AlgorithmName { get; set; }
    public DateTime UTCStartTime { get; s

Adding back deleted User Profile Property


I've made a bit of an error. My SharePoint User Synchroniztion was all setup and working with My Sites and My Profile but the address was being duplicated. I removed one of the user profile properties under the contact collection. Now SharePoint can't render the My Profile pages. With logging turned up I get the following:

Unhandled exception caught during execution of Microsoft.SharePoint.Portal.PageBase::ErrorHandler()

Watson bucket parameters: SharePoint Server 2010, ULSException14, 06d8f9f3 "sharepoint portal server", 0e00129b "14.0.4763.0", b2be5063 "microsoft.office.server.userprofiles", 0e001294 "14.0.4756.0", 4b9b2905 "sat mar 13 05:56:21 2010", 0000082d "0000082d", 00000049 "00000049", 10bc7a81 "propertynotdefinedexception", 37706d61 "7pma"

Microsoft.Office.Server.UserProfiles.PropertyNotDefinedException: Property Not Defined: SPS-Location.  An administrator must create this property in the Profile Administration tool.    at

Problem is if I try to recreate a User Property with the name SPS-Location it won't let me so how do I get this back?



Some AD attributes unavailable for User Property mappings?


Has anyone noticed that some AD attributes that were available in 2007 for Profile Property Mappings are no longer available in 2010?  We pull data from the AD attribute "destinationIndicator" in MOSS 2007, but it seems to be unavailable in 2010.  Wondering if any others are unavailable.

I'm patched all the way up through the August CU, but still no luck on seeing this AD attribute.


sharepoint 2010 user information list custom property



i added a custom property to the user list and wish to display it. when i go to "user info list" > "list settings" > "edit view" i see 39 properties to choose from. how can i remove these default values and add my own properties to the view.




The 'LastLogin' property on 'User' could not be set to a 'null' value. You must set this prope


I get the following error message when running a LINQ statement to return a User object:

The 'LastLogin' property on 'User' could not be set to a 'null' value. You must set this property to a non-null value of type 'DateTime'.

The User class is generated by Entity Framework. How does one handle setting properties from database fields that are NULL?

Dim user As User = rep.Users.FirstOrDefault(Function(x) x.Username = userName)

The above line of code is the line that errors.

Thanks for any help

Programmatically adding user profile properties fails when adding a multivalued property


I have written a console application that adds a custom section to the User Profile Properties and then adds properties under that section. The code works fine when adding CoreProperties of type string (Single Value) and mapping each property to an Active Directory field. However the code always fails when mapping a string (Multi Value) property to an AD property. I have researched the errors I present below but cannot see what the solution might be.


    private static void AddCustomProperties(string strUrl)
      Console.WriteLine("Adding custom properties under section '" + DisplayName + "'.......");
      using (SPSite siteColl = new SPSite(strUrl))

        SPServiceContext serviceContext = SPServiceContext.GetContext(siteColl);
        UserProfileConfigManager upcm = new UserProfileConfigManager(serviceContext);
        CorePropertyManager cpm = upcm.ProfilePropertyManager.GetCoreProperties();
        ProfilePropertyManager ppm = up
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend