.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

Programmatically add target audience field

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :SharePoint


I have a list I'm creating on the fly and also creating the fields for that list... I have created a HTML filed like so:

 HtmlField htmlField = new HtmlField(pollsList.Fields, "HTML", "HTML_Field");
      field = (SPField)pollsList.Fields.GetField("HTML_Field");
      field.DefaultValue = " ";
      field.Description = "Short text field can add link to discussions";

What I cannot seem to find any help with is how can I create the Target Audience field for the list???




View Complete Post

More Related Resource Links

Target Audience in Share Point 2010

Hi there, We've managed to migrate  MOSS 2007 to MOSS 2010 for one of our customer. Everything went well except Target Audience. Sharepoint2010 does not seem to recognise the AD groups and no matter how many times I reset them, I see the error of "No exact match found". Appreciate if someone can advice.   Thanks.    

Is there a way to manually or programmatically set the dataset field's data type? This dataset is

Is there a way to manually or programmatically set the dataset field's data type?  The reason I am asking this question is that I am trying to sum a column of data in a report.  I noticed it is possible to sum a column of data if the datatype of a field in the .rdl file is of type <rd:TypeName>System.Int32</rd:TypeName>. Whereas it is not possible to sum a column of data in an .rdl file when the datatype of a field is <rd:TypeName>System.String</rd:TypeName> . When I create a dataset in BIDS 2008, by default, the dataset gives a field a type System.String.  I need to be able to change the field type to System.Int32 in order to sum the column. My datasource is a web service.  The results returned by the web service method has a datatype of int as follows: <xs:element name="Dollars" type="xs:int" minOccurs="0" /> So it seems the dataset created by the reporting services is giving my webservice a type of System.String. Is there some way of manually changing the type? thanks, Lloyd

MOSS 2010 Issue with Target Audience

Hi there, We've managed to migrate  MOSS 2007 to MOSS 2010 for one of our customer. Everything went well except Target Audience. Sharepoint2010 does not seem to recognise the AD groups and no matter how many times I reset them, I see the error of "No exact match found". Here is the scenario : Application pool user has necessary rights as MOSS able to find AD groups. However, once MOSS locates AD groups and after we assign relevant AD group to a particular web part, save the web part and if I happen to edit the web part then we found ""No exact match found" in the Target Audience. One more thing, this behaviour is happening only for HOME page. For this reason, we tried to recreate the entire webpage, but the issue ""No exact match found" still remains.   Kindly advice. Thanks

How programmatically change Additional Column Settings - Show field?


Hello. I use the SPFieldUser in my list. I can change Additional Column Settings - Show field: "Name with Presense" on the "Name (with Picture and details)" using the WSS Web interface. How do it programmatically, using Object Model WSS?

Show or hide programmatically based on audience


I'm trying to either show or hide a datalist control based on a users Audience.

      AudienceLoader audienceLoader = AudienceLoader.GetAudienceLoader();

      string audienceFieldValue = "United States";

      if ((AudienceManager.IsCurrentUserInAudienceOf(audienceLoader, audienceFieldValue, false)))
        DataList2.Visible = true;
        DataList2.Visible = false;

I have tried couple different things this is where I'm at now... any help would be appreciated.




How do I set the target audience using Sharepoint Designer workflow



I need to set the target audience in a list based on a column called "DocType" Im hoping I can do this using a workflow as Ive been getting to grips using the workflow designer lately.

I have tried setting an Initiation with the default string being the target audience group, then set the target audience field to be the initiation value

This does send the string to my list but only if I edit the list and validate the target audience address

Does anyone know how I can validate the audience address using the workflow designer~?


Many thanks in advance

Programmatically creating a Person or Group type field Textbox (similar to 'Assigned To' field in Ta


In our ASP.NET application created with SharePoint object model, we have a user interface with a Contact Person TextBox, we want this TextBox to be similar to the “Assigned To” filed in out-of-the-box Task List where you can search for a particular site user by typing in his/her name. How can we achieve this functionality programmatically?

Thanks in advance………

Target Audience Option Not Available

I was working on webparts in a single page,i assigned target audience to each webparts.after a day i rebooted my server then my webparts are not showing the target audience option ,and all webparts are shown instead of user specific one.Please Help....
From Tony

Target Audience is missing while editing webpart



i have configured some webparts with target Audience,

now, the Target audience filed is missing in edit web part.

Please guide me to find where the mistake is.

Thanks in advance, Akilaskk 

Programmatically remove link from lookup field

I've found this link describing an approach to remove the link from a lookup field via javascript. Is there an other way except adding a content editor webpart to every site with lookup fields? Like setting a property for the lookup field? Thanks

SharePoint group name duplicacy causing issues in target audience


We are editing the target audience property of a document in a library. We have multiple SharePoint groups like the following



In PeoplePicker, both the above groups are found. If I select the first one, and come back we get Found No Matches and it tells that more than one group are present. If I select one of them and save, when I come back to check via view properties, the Target Audience property is blank.

This kind of problem is present in many internet posts, but I did not see any clear resolution. Is it a result of any recent windows patch?


How To Programmatically Get the DataType of a SharePoint Field


I am assigning metadata properties programmatically to a SharePoint field using the syntax:

curitem.Item["fieldname"] = "Value";

I would like to make it more dynamic and read the SharePoint fields from a field-mapping datatable created by the user so that the user controls which value from an spreadsheet gets assigned into a SharePoint field.

To do this I would like to check what the DataType of the SharePoint field is before assigning the value into it.

I have checked the .GetType() method but it does not seem to return anything that I can use or I do not know how to use the return value.

Is it possible to get the DataType?

Site Navigation Settings not finding any objects for the Audience field


I wanted to create a link in the Global Navigation bar for a page I just created. I want that only one user in the site can access it. So, I went and added a new link, filled up the title and URL text boxes and tried to add a user in the audience field.


The system gives me the following error.

Check Names 

AD groups not appearing in Target Audience



I cannot get Sharepoint to pickup any of my Active Directory security groups when i use target audience - Distrubution/Security groups. I use many different AD groups fine in the rest of Sharepoint but it is totally blank in the Select Audience dialogue box. Any ideas would be appreciated


Target Audience


i m having  the same problem in web part implemented in the master page but it always seems that the target audience control is not working in the master page as i want to hide some part of my master page according to users role.....

can anybody help me out on this ....


How to Create Auto increment Request number for browser enable infopath form field Programmatically?

hi all,

i have created an infopath which have one request no. field and it will auto increment when click on add new item on sharepoint Document library

field contains (highest value of column request no. +1 )  when infopath will open in browser.

What i have done on this:i have create new data connection on sharepoint library and then pick document library then choose ID field and insert function in the field max(ID)+1.

help me



Export SharePoint List to Excel Spreadsheet Programmatically using C#

In SharePoint applications, Custom Lists are used to store business data and Document Libraries to store the documents. But for data manupulation and analysis, Microsoft Excel provides very rich features as compared to SharePoint Lists. That's why people still loves to work on Microsoft Excel Sheets.
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