Vertically display list items in a webpart

I previously added a webpart that displayed information in a vertical fashion by selecting the Newsletter style. However, whenever I try to duplicate this on another page, all the date displays horizontially. Please note I am not allowed to use Designer
to solve this.
1. Is there a reason that I would not be able to duplicate this?
2. If I cannot duplicate this, is there any other way, outside of Designer, to have a list display vertically?
I am pulling my hair out as it has worked in the past and now I cannot duplicate it. Thanks for any help you can provide!

Have you tried the Pane or Boxed views?  I believe that these render list items vertically.
If these end up being insufficient, than you'd need to look at dataviews, xslt views or customised Content Query Web Parts (CQWP).
One solution involving a CQWP is to add the code below to the bottom of the ItemStyle.xsl in the Styles Gallery on your root site.  You then link the CQWP to your list and you'll see a view called PageBlocksWithoutDescription.
Credit to Suresh from
this thread for the original solution
<xsl:template name="PageBlocksWithoutDescription" match="Row[@Style='PageBlocksWithoutDescription']" mode="itemstyle">
<xsl:variable name="SafeImageUrl">
<xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
<xsl:with-param name="UrlColumnName" select="'PublishingPageImage'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="LinkTarget">
<xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
</xsl:variable>
<div>
<ul style=" width:1000px;">
<a href="{@BlockUrl}">
<li style="background-color: #F99E2E;color: #FFF;display: inline-table;font-family: Verdana;font-size: 13px;height: 130px;list-style: none outside none;padding: 10px 15px 5px 17px;width: 269px;margin:0px 3px 12px 8px;display:inline-block;float:left;">
<div style=" font-family:Segoe UI Semibold; font-size: 16px;text-transform:uppercase">
<xsl:value-of select="$DisplayTitle"/>
</div>
</li>
</a>
</ul>
</div>
</xsl:template>
Steven Andrews
SharePoint Business Analyst: LiveNation Entertainment
Blog: baron72.wordpress.com
Twitter: Follow @backpackerd00d
My Wiki Articles:
CodePlex Corner Series
Please remember to mark your question as "answered" if this solves (or helps) your problem.

Similar Messages

  • Wrong numbering of elements styled with "display: list-item; list-style-type: decimal;"

    Following code :
    <!DOCTYPE html>
    <style type="text/css">
    div {
    display: block;
    margin-left: 2em;
    span {
    display: list-item;
    list-style-type: decimal;
    </style>
    &lt;div>
    &lt;span>first&lt;/span>
    &lt;span>second&lt;/span>
    &lt;span>third&lt;/span>
    &lt;/div>
    Displays as :
    0. first
    0. second
    0. third
    while looking fine in other browsers (checked IE7, chrome, opera, safari...)

    updated code snap...

  • Display list items based on another list item

    Hi All
                I want to display the list item based on another list item, but its not working.
    This is my code:
    /*WHEN-NEW-FORM-INSTANCE*/---Its working.
    DECLARE
       rg_district   recordgroup;
       rg_name       VARCHAR2 (40) := 'district';
       vtemp         NUMBER;
    BEGIN
       rg_district := FIND_GROUP (rg_name);
       IF ID_NULL (rg_district)
       THEN
          rg_district :=
             CREATE_GROUP_FROM_QUERY (rg_name,
                                      'select dist,dist from district_mas'
          vtemp := POPULATE_GROUP (rg_district);
          POPULATE_LIST ('BLOCK3.DISTRICT', rg_name);
       END IF;
       END;
    */WHEN-LIST-CHANGED*/---Not working. Cannot populate the list based on the List
       DECLARE
       rg_branch   recordgroup;
       rg_name1     VARCHAR2 (1000) := 'branch';
       vtemp       NUMBER;
    BEGIN
       rg_branch := FIND_GROUP (rg_name1);
       IF NOT ID_NULL (rg_branch)
       THEN
          DELETE_GROUP (rg_name1);
          rg_branch :=
             CREATE_GROUP_FROM_QUERY
                ('rg_branch',
                    'SELECT branch FROM dist_branch WHERE district IN (SELECT DIST FROM DISTRICT_MAS WHERE DISTRICT ='
                 || :BLOCK3.DISTRICT
          vtemp := POPULATE_GROUP (rg_branch);
          POPULATE_LIST ('BLOCK3.BRANCH', rg_branch);
       END IF;
       END;
    Table:
    CREATE TABLE DISTRICT_MAS
      DIST  VARCHAR2(100 CHAR)
    CREATE TABLE DIST_BRANCH
      DISTRICT  VARCHAR2(100 CHAR),
      BRANCH    VARCHAR2(100 CHAR)
    Values:
    insert into district_mas values('chennai');
    insert into district_mas values('coimbatore');
    insert into dist_branch values('chennai','chennai_north');
    insert into dist_branch values('coimbatore','Podanur');
    Regards
    Shagar M

    Hmm, not tested.
    try this..
    --*/WHEN-LIST-CHANGED*/
       DECLARE
       rg_branch       recordgroup;
       rg_name1     VARCHAR2 (1000) := 'branch';
       vtemp        NUMBER;
       QT            VARCHAR2(10) :='''';
    BEGIN
       rg_branch := FIND_GROUP (rg_name1);
       IF NOT ID_NULL (rg_branch)
       THEN
          DELETE_GROUP (rg_name1);
          rg_branch :=
             CREATE_GROUP_FROM_QUERY
                ('rg_branch',
                    'SELECT branch FROM dist_branch WHERE district IN (SELECT DIST FROM DISTRICT_MAS WHERE DISTRICT ='
                 || QT||:BLOCK3.DISTRICT||QT||')'
          vtemp := POPULATE_GROUP (rg_branch);
          POPULATE_LIST ('BLOCK3.BRANCH', rg_branch);
       END IF;
    END;
    Hope this works..
    Hamid

  • Query list items and display in client webpart..

    I am using the code below to display list items in clientwebpart but getting errors.Below is the code written in js file..What is wrong with the code??
    Error:javaScript runtime error: Unable to set property 'innerText' of undefined or null reference 
    'use strict';
    var context = SP.ClientContext.get_current();
    var user = context.get_web().get_currentUser();
    var web;
    var spHostUrl;
    var parentcontext;
    spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    parentcontext = new SP.AppContextSite(context, spHostUrl);
    web = parentcontext.get_web();
    var list = web.get_lists().getByTitle("ListsTask");
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml("");
    this.listItems = list.getItems(camlQuery);
    context.load(listItems);
    context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),
        Function.createDelegate(this, this.onQueryFailed));
    // This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
    $(document).ready(function () {
        getUserName();
    // This function prepares, loads, and then executes a SharePoint query to get the current users information
    function getUserName() {
        context.load(user);
        context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
    // This function is executed if the above call is successful
    // It replaces the contents of the 'message' element with the user name
    function onGetUserNameSuccess() {
        $('#message').text('Hello ' + user.get_title());
    // This function is executed if the above call fails
    function onGetUserNameFail(sender, args) {
        alert('Failed to get user name. Error:' + args.get_message());
    function getQueryStringParameter(urlParameterKey) {
        var params = document.URL.split('?')[1].split('&');
        var strParams = '';
        for (var i = 0; i < params.length; i = i + 1) {
            var singleParam = params[i].split('=');
            if (singleParam[0] == urlParameterKey)
                return decodeURIComponent(singleParam[1]);
        function onQuerySucceeded() {
            $("#results").empty();
            var listInfo = '';
            var listEnumerator = listItems.getEnumerator();
            listInfo += "<table><tr><th>Id</th><th>Title</th></tr>";
            while (listEnumerator.moveNext()) {
                var listItem = listEnumerator.get_current();
                listInfo += '<tr><td>' + listItem.get_item('ID') + '</td>'
                    + '<td>' + listItem.get_item('Title') + '</td>'
                    + '</tr>\n';
            listInfo += '</table>';
            $("#results").html(listInfo);
        function onQueryFailed(sender, args) {
            $("#results").empty();
            $("#results").text('Request failed. ' + args.get_message() +
                '\n' + args.get_stackTrace());

    HI,
    I have modified your code.
    'use strict';
    var context = SP.ClientContext.get_current();
    var user = context.get_web().get_currentUser();
    var web;
    var spHostUrl;
    var parentcontext;
    spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    parentcontext = new SP.AppContextSite(context, spHostUrl);
    web = parentcontext.get_web();
    // This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
    $(document).ready(function () {
        getUserName();
        getitems();
    // This function prepares, loads, and then executes a SharePoint query to get the current users information
    function getUserName() {
        context.load(user);
        context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
    function getitems()
        var list = web.get_lists().getByTitle("ListsTask");
        var camlQuery = new SP.CamlQuery();
        camlQuery.set_viewXml("");
        this.listItems = list.getItems(camlQuery);
        context.load(listItems);
        context.executeQueryAsync(onQuerySucceeded1, onQueryFailed1);
    // This function is executed if the above call is successful
    // It replaces the contents of the 'message' element with the user name
    function onGetUserNameSuccess() {
        $('#message').text('Hello ' + user.get_title());
    // This function is executed if the above call fails
    function onGetUserNameFail(sender, args) {
        alert('Failed to get user name. Error:' + args.get_message());
    function getQueryStringParameter(urlParameterKey) {
        var params = document.URL.split('?')[1].split('&');
        var strParams = '';
        for (var i = 0; i < params.length; i = i + 1) {
            var singleParam = params[i].split('=');
            if (singleParam[0] == urlParameterKey)
                return decodeURIComponent(singleParam[1]);
        function onQuerySucceeded1() {
            $("#results").empty();
            var listInfo = '';
            var listEnumerator = listItems.getEnumerator();
            listInfo += "<table><tr><th>Id</th><th>Title</th></tr>";
            while (listEnumerator.moveNext()) {
                var listItem = listEnumerator.get_current();
                listInfo += '<tr><td>' + listItem.get_item('ID') + '</td>'
                    + '<td>' + listItem.get_item('Title') + '</td>'
                    + '</tr>\n';
            listInfo += '</table>';
            $("#results").html(listInfo);
        function onQueryFailed1(sender, args) {
            $("#results").empty();
            $("#results").text('Request failed. ' + args.get_message() +
                '\n' + args.get_stackTrace());
    But still not able to get list items, i m finding soultion.
    Thanks
    varinder

  • Conditionally diplaying items in List item

    Hi,
    It is appreciably if anyone could help me, how we could conditionally display list items. Depending on the condition the certain items should be greyed out. Our environment is 10g Forms on Windows XP.
    Thanks with Regards.
    Hector

    Do you want to disable the list or the values in the list?
    For the first one use set_item_property: enabled property_false/true based on your condition.
    The second one is not possible.
    Monica

  • List items as grouped elements

    Hi,
    In 'Select List Item' , I want to display list items as grouped elements. Assume that grouping the child items based on its master code.
    Eg: [ Fruits ]
    Apple
    Orange
    Goa
    [ Animals ]
    Tiger
    Lion
    Elephant
    [ Birds ]
    ...... etc
    How can I do it?
    Regards
    Mohan

    Mohan wrote:
    In 'Select List Item' , I want to display list items as grouped elements. Assume that grouping the child items based on its master code.
    Eg: [ Fruits ]
    Apple
    Orange
    Goa
    [ Animals ]
    Tiger
    Lion
    Elephant
    [ Birds ]
    ...... etc
    How can I do it?The select list item must generate HTML <tt>optgroup</tt> elements, via an item plug-in or some other technique, e.g.
    {thread:id=1115902}
    {message:id=4516761}

  • List Item Search Capability Is only Available in Default Style Views

    Hello,
            I am using SharePoint 2013 and I am impressed with the List Search Capability that is available when you use the Default Style view option.  What I am not impressed with is that the capability in not in all
    the other styles like shaded.  Is there any method that I can use to activate that functionality throughout all of my lists using any type of style like shaded.  For my organization it is a 508 compliance issue.
    Thank You
    PRSharePoint

    Hi,
    It is by default that view styles other than default has no inline Search box. In SharePoint 2013, if you need to customize list view style, you need to use JSlink property to change the fields' view:
    http://zimmergren.net/technical/sp-2013-using-the-spfield-jslink-property-to-change-the-way-your-field-is-rendered-in-sharepoint-2013
    http://blog.vgrem.com/2013/04/14/customize-the-rendering-of-a-list-view-in-sharepoint-2013-displaying-list-items-in-accordion/
    http://sharepoint.stackexchange.com/questions/101329/list-styling-in-sharepoint-2013
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Retrieve list items from the textbox text value and display the dropdownlist item for that particular list item

    hi,
     I have created a custom list in my sharepoint :
    List1 name:   employeedepartment  -
                   Title       empdepartment
                   A             D1
                   B             D2
                   C             D3 
    List2  name:  employeedetails  
     emptitle            empname       empdepartment(lookup) --> from the list "employeedepartment"
       x                     Ram                 D1
       y                     Robert             D2
       z                     Rahim              D3
    My task is to create a custom webpart that will be for searching this employee details by entering emptitle
    For this, i have created a visual webpart using visual studio 2010, my webpart will be like this:
    emptitle  --->  TextBox1                        Button1--> Text property : Search
    empname---> TextBox2
    empdepartment-->  DropDownList1
    For this, i wrote the code as follows:
    protected void Button1_Click(object sender, EventArgs e)
                using (SPSite mysite = new SPSite(SPContext.Current.Site.Url))
                    using (SPWeb myweb = mysite.OpenWeb())
                        SPList mylist = myweb.Lists["employeedetails"];
                        SPQuery query = new SPQuery();
                        query.Query = "<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + TextBox1.Text.ToString() + "</Value></Eq></Where>";
                        SPListItemCollection myitems = mylist.GetItems(query);
                        if (myitems.Count > 0)
                            foreach (SPListItem item in myitems)
                                string a1 = Convert.ToString(item["empname"]);
                                string a2 = Convert.ToString(item["empdepartment"]);
                                TextBox2.Text = a1;           // displaying   properly                    
                                //DropDownList3.SelectedIndex = 1;                           
     It is showing the list item in textbox according to the item entered in the textbox1... But I am stuck to show in the dropdown list. 
    Suppose, if i enter X in textbox and click on search, then dropdownlist need to show D1,
                               for Y --> D2 and for Z-> D3... like that.
    What code do i need to write in the button_click to show this... 
    Please don't give any links...i just want code in continuation to my code.

    Hi,
    Since you have got the data you want with the help of SharePoint Object Model, then you can focus on how to populate values and set an option selected in the Drop Down List.
    With the retrieved data, you can populate them into the Drop Down List firstly, then set a specific option selected.
    Here is a link will show how to populate DropDownList control:
    http://www.dotnetfunda.com/articles/show/30/several-ways-to-populate-dropdownlist-controls
    Another link about select an item in DropDownList:
    http://techbrij.com/select-item-aspdotnet-dropdownlist-programmatically
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to display all items titles from custom list with checkbox to select for each user

    Hi All,
    I have a requirement in a sharepoint 2013 development project.
    A custom list items will be created by admin with the following columns:
    Title
    Hyperlink
    User business unit (This column which is a metadata will be a userprofile property)
    In a page/form I have to display the list of titles with a check box based on each user business unit and each user will be allowed to check the list of titles and hit save. And then have to display the list chosen by the user in a webpart.
    If they want to modify their list they have to go to the page/form again and will uncheck the list.
    Am not sure whether I can achieve this through sharepoint out of box feature, I have not done any custom development.
    Please provide your valuable suggestions/ideas on this. Thanks for looking on this !!!

    Hi,                                                             
    Per my knowledge, there are no such OOTB features can meet your requirement, however, there is a workaround that if you can modify your requirement a bit.
    Based on your description, you want different users be able to select values from a list and generate a list own by them.
    If this is what you mean, we can do it like this:
    1. Create another list "Users" which stores the names of every users;
    2. Create a list "Result" which will be available for every user to add their own items, this list will have four Lookup columns and they look up to the "Users" list and the
    list you mentioned before;
    3. Users can add items into "Result" list by selecting the needed values from the other two list, then the items he/she created will be connected to them with the help of the
    Lookup column which looks up to the "Users" list.
    4. You can take use of the OOTB permission management of list to control the access of each item in the "Result" list, and it will be easier for you to manage and filter the
    information you needed.
    The links below about Lookup column for your reference:
    http://office.microsoft.com/en-us/sharepoint-server-help/create-list-relationships-by-using-unique-and-lookup-columns-HA101729901.aspx
    http://www.dummies.com/how-to/content/lookup-columns-in-sharepoint-2010.html
    Best regards
    Patrick Liang
    TechNet Community Support

  • Webpart button that assigns user to list item

    I need a button event that when clicked assigns the user to the list item that is selected from a checkbox. All from a webpart. Unfortunately for me corporate will not let us use Visual Studio (security access to critical info and what not).
    I have access to InfoPath and SharePoint designer content editor and such. I tried circumventing it all together and built a button in the form that only shows when in edit mode from the webpart. The button simply assigns user to the people picker, which shows
    in InfoPath preview. But when I try to do the same in the live edit able list item the people picker just blinks and nothing fills the text field. I even tried using a simple text box which worked but only for userid()  not display name. Anybody know
    why people picker field appears blank in the live version? Or can someone point me to where I can build an outright webpart button that fills my assignto field? I don't quite understand how to do it. What I have seen has been done with visual studio. Any help
    would be great.

    Hi Jack,
    First of all, you can not create a coded web part using SPD.
    What you can do is create custom page (aspx) and do inline coading. (http://social.technet.microsoft.com/Forums/sharepoint/en-US/211d3c10-ab83-473f-95b4-83b0174f9dd7/how-to-add-custom-web-part-to-sharepoint-page-by-using-sharepoint-designer?forum=sharepointgeneralprevious)
    Custom page allows you to add c# code with enable page compiling with
    <PageParserPaths>
    <PageParserPath VirtualPath="/PageLibrary/MyCustomPage.aspx" CompilationMode="Always" AllowServerSideScript="true" />
    </PageParserPaths>
    OR
    Write all into Content editor web part on that page.(http://social.technet.microsoft.com/Forums/sharepoint/en-US/f6d8c243-71af-4a98-bdb6-750d4dd9dc27/check-box-and-button-in-content-editor-web-part?forum=sharepointgeneralprevious)
    Here you can use Javascript only and not "c#" due to security issue.(http://social.msdn.microsoft.com/Forums/sharepoint/en-US/74b676f0-3509-4b11-8725-b9f2626371e9/content-editor-web-part-and-c?forum=sharepointdevelopmentlegacy)

  • Request help to display a list with parent and child list item.

    I created a static list with items A,B,C and a child item A1 under parent A. I chose the template "vertical Side bar list". I am using theme 10 (sand) for my application. I created page 0 and am displaying the list on page template region position2. I am able to see the side bar with options A,B,C. But am not able to see the child option A1 when I click on Option A. I tried using 'DHTML MENU WITH SUB LIST' but When I click on option A, the child entry A1 is showing over the B and C options. I know this might be a pretty basic functionality. I am new to APEX and am just learning. I appreciate any help you give me.

    Mr.Backstrom,
    I have changed the list template overide to dhtml Tree. And now the list is being displayed as vertical unordered list with bullets. Is it possible to take off the bullets? Thank you for your time.
    Suma.

  • Set vertical gap of menu items, list items...

    Hi, is there any way to adjust the vertical gaps between menu items, between list items, between combo box list lits? I am trying to make my Java application look like Windows application, but the vertical gaps in these Java components are just too big. Thanks!
    Yu

    Sorry for the massive bit of code, but you can use this to display the UI defaults and decide what to change if you want to try to affect (simple) global changes to the look and feel:
    It's far from beautiful but I've found it helpful from time to time.
    import javax.swing.JFrame;
    import javax.swing.Icon;
    import javax.swing.JLabel;
    import javax.swing.JScrollPane;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.UIManager;
    import javax.swing.UIDefaults;
    import javax.swing.border.Border;
    import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.Component;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Insets;
    import java.util.Iterator;
    import java.util.Set;
    import java.util.TreeSet;
    import java.util.Comparator;
    import java.util.Enumeration;
    public class DefaultsDisplayer extends JFrame
         private static class ResourceLabel extends JLabel
              private ResourceLabel(Object key, Object value)
                   super(key.toString());
                   if(value instanceof Icon)
                        setIcon(new SafeIcon((Icon)value));
                   else if(value instanceof Color)
                        setIcon(new ColorIcon((Color)value));
                   else if(value instanceof Font)
                        setIcon(new ColorIcon(null));
                        setFont((Font)value);
                   else if(value instanceof Border)
                        setIcon(new ColorIcon(null));
                        setBorder(new SafeBorder((Border)value));
                   else if(value instanceof String)
                        setIcon(new ColorIcon(null));
                        setText(key.toString() + ": '" + value.toString() + "'");
                   else
                        setIcon(new ColorIcon(null));
                    setText(key.toString() + ": " + value.getClass().getName());
         private static class SafeIcon implements Icon
              private Icon icon;
              private SafeIcon(Icon icon)
                   this.icon = icon;
              public int getIconWidth()
                   return icon.getIconWidth();
              public int getIconHeight()
                   return icon.getIconHeight();
              public void paintIcon(Component comp, Graphics g, int x, int y)
                   try
                        icon.paintIcon(comp, g, x, y);
                   catch(Exception e)
         private static class ColorIcon implements Icon
              private Color color;
              private ColorIcon(Color color)
                   this.color = color;
              public int getIconWidth()
                   return 32;
              public int getIconHeight()
                   return 32;
              public void paintIcon(Component comp, Graphics g, int x, int y)
                   if(color == null)
                        return;
                   g.setColor(color);
                   g.fillRect(x, y, 32, 32);
         private static class SafeBorder implements Border
              private Border border;
              private SafeBorder(Border border)
                   this.border = border;
              public Insets getBorderInsets(Component c)
                   try
                        return border.getBorderInsets(c);
                   catch(Exception e)
                        return new Insets(0, 0, 0, 0);
              public boolean isBorderOpaque()
                   return border.isBorderOpaque();
              public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
                   try
                        border.paintBorder(c, g, x, y, w, h);
                   catch(Exception e)
         private static class ObjectComparator implements Comparator
              public int compare(Object o, Object p)
                   String s = o.toString().toLowerCase();
                   String t = p.toString().toLowerCase();
                   return s.compareTo(t);
         public DefaultsDisplayer()
              super("Default Displayer");
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Box box = new Box(BoxLayout.Y_AXIS);
              UIDefaults defaults = UIManager.getDefaults();
              Set keys = new TreeSet(new ObjectComparator());
              for(Enumeration e = defaults.keys(); e.hasMoreElements(); )
                   keys.add(e.nextElement());
              Object key, value;
              JLabel label;
              for(Iterator i = keys.iterator(); i.hasNext(); )
                   key = i.next();
                   value = defaults.get(key);
                   label = new ResourceLabel(key, value);
                   box.add(label);
                   box.add(box.createVerticalStrut(5));
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(new JScrollPane(box), BorderLayout.CENTER);
              setLocation(50, 50);
              setSize(500, 500);
              doLayout();
              setVisible(true);
         public static void main(String[] args)
              new DefaultsDisplayer();
    }

  • Adding an item to a List when clicking a WebPart Properties 'OK' button

    Hi all,
    I wonder if someone can help me. Im new to SharePoint Programming but learning slowly. 
    I have a superb Web Part downloaded from Codeplex which essentially is a Countdown Timer in jQuery. (spCountdown) The code itself works perfectly however I want to tweak it, in what I thought would be a relatively easy thing to do.
    In the Web Part properties of the solution, there is a textbox where you enter the Date/Time which you wish to set the countdown timer. When I click 'OK' to submit the WebPart, I would like the date value in the textbox to be added to a List as a new List
    item. I've got the code to add the List item (or what im think is the correct code) but what I cant do is get the function to execute when the WebPart 'OK' button is clicked. 
    Now, I have downloaded the source code which is available but I cant fathom how to hook the 'Update List Item' code onto the onclick event of the button (as I cant find an onclick event!). Any help to advise me what to do would be appreciated.
    My code to add the date to the new List:
    // create item in Deadline Configuration List
    using (SPSite oSiteCollection = new SPSite(SPContext.Current.Site.Url))
    using (SPWeb oWeb = oSiteCollection.OpenWeb())
    SPList oList = oWeb.Lists["DLConfig"];
    SPListItem oListItem = oList.Items.Add();
    oListItem["Title"] = "Deadline Date";
    oListItem["TaskDueDate"] = new DateTime(WebPart.TargetDate.Year, WebPart.TargetDate.Month, WebPart.TargetDate.Day);
    oWeb.AllowUnsafeUpdates = true;
    oListItem.Update();
    Original WebPart Code:
    SPCountdownWebpart.cs
    using System;
    using System.ComponentModel;
    using System.Web.UI.WebControls.WebParts;
    namespace SPCountdown.SPCountdownWebPart
    [ToolboxItemAttribute(false)]
    public class SPCountdownWebPart : WebPart
    // Visual Studio might automatically update this path when you change the Visual Web Part project item.
    private const string _ascxPath = @"~/_CONTROLTEMPLATES/SPCountdown/SPCountdownWebPart/SPCountdownWebPartUserControl.ascx";
    protected override void CreateChildControls()
    var control = Page.LoadControl(_ascxPath);
    if (control != null)
    ((SPCountdownWebPartUserControl)control).WebPart = this;
    Controls.Add(control);
    [Category("Countdown Settings"),
    Personalizable(PersonalizationScope.Shared),
    WebBrowsable(true),
    WebDisplayName("Target Date/Time"),
    WebDescription("Please enter the target date/time for countdown.")]
    public DateTime TargetDate { get; set; }
    SPCountdownWebpartUserControl.cs
    using System;
    using System.Web.UI;
    using Microsoft.SharePoint;
    namespace SPCountdown.SPCountdownWebPart
    public partial class SPCountdownWebPartUserControl : UserControl
    public SPCountdownWebPart WebPart { get; set; }
    public SPCountdownWebPartUserControl()
    PreRender += SPCountdownWebPartUserControl_PreRender;
    void SPCountdownWebPartUserControl_PreRender(object sender, EventArgs e)
    // parse date from properties
    var targetDateString = string.Format("{0},{1},{2},{3},{4},{5}",
    WebPart.TargetDate.Year,
    WebPart.TargetDate.Month - 1, //uses 0-based index
    WebPart.TargetDate.Day,
    WebPart.TargetDate.Hour,
    WebPart.TargetDate.Minute,
    WebPart.TargetDate.Second);
    // js sources
    const string jqueryScript = "<script type='text/javascript' src='/_layouts/SPCountdown/js/jquery-1.10.2.min.js'></script>";
    const string countdownScript = "<script type='text/javascript' src='/_layouts/SPCountdown/js/jquery.countdown.min.js'></script>";
    // create javascript implementing countdown
    const string jsCountdownFormat = "<script type='text/javascript'>$(function () {{var targetDate = new Date({0});$('#defaultCountdown').countdown({{until: targetDate}});}});</script>";
    var jsCountdown = string.Format(jsCountdownFormat, targetDateString);
    // register client scripts
    var cs = Page.ClientScript;
    if (!cs.IsClientScriptBlockRegistered("jQuery"))
    cs.RegisterClientScriptBlock(
    GetType(),
    "jQuery",
    jqueryScript);
    if (!cs.IsClientScriptBlockRegistered("jsCountdownScript"))
    cs.RegisterClientScriptBlock(
    GetType(),
    "jsCountdownScript",
    countdownScript);
    if (!cs.IsClientScriptBlockRegistered("jsCountdown"))
    cs.RegisterClientScriptBlock(
    GetType(),
    "jsCountdown",
    jsCountdown);
    protected void Page_Load(object sender, EventArgs e)
    Can anyone help me with where I need to implement my code to get the List Item to be created when the Web Part properties are set?
    Thanks in advance.
    Rick Lister
    -=Stylus=-

    Hi,
    Please refer below link regarding web part custom properties,
    I think you need to write code under ApplyChanges() Method.I am not sure. Just try it once.
    http://sharepointkitchen.blogspot.in/2014/10/custom-web-part-properties-approach-2.html
    Don't forget to mark it as an Answer if it resolves your problem or Vote Me if it useful.
    Mahesh

  • WebPart is raising the following error "Invalid data has been used to update the list item.The field you are trying to update may be read only"

    I have created a farm solution and then i deploy it to SharePoint server, the code looks as follow, and i use it to update a page info values (as the current page values represents old info):-
    [ToolboxItemAttribute(false)]
    public partial class VisualWebPart1 : WebPart
    // Uncomment the following SecurityPermission attribute only when doing Performance Profiling using
    // the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
    // for production. Because the SecurityPermission attribute bypasses the security check for callers of
    // your constructor, it's not recommended for production purposes.
    // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
    public VisualWebPart1()
    protected override void OnInit(EventArgs e)
    base.OnInit(e);
    InitializeControl();
    using (SPSite site = new SPSite(SPContext.Current.Site.Url))
    using (SPWeb web = site.OpenWeb())
    SPList list = web.Lists["Pages"];
    web.AllowUnsafeUpdates = true;
    foreach (SPListItem items in list.Items)
    items["Author"] = "SharePoint";
    items["Created"] = "01/08/2014 01:44 PM";
    items.Update();
    list.Update();
    web.AllowUnsafeUpdates = false;
    protected void Page_Load(object sender, EventArgs e)
    but when i try adding this web part to a page i got the following error:-
    Invalid data has been used to update the list item.The field you are trying to update may be read only
    so can anyone advice?

    i only changed lines bitween 
    web.AllowUnsafeUpdates = true;
    and
    web.AllowUnsafeUpdates = false;
    and other parts of code remains without change
    so it will updates all pages in current web
    yaşamak bir eylemdir

  • List item display in Oracle forms 10g

    hi,
    I have created the list item with pop-list in forms.When i retrieve the data using record group in the list item ,i need to display two column data in single list item i.e emp id , emp name .
    select emp_id,emp_name from emp where mgr_id = 100;
    i tried this query in record group but its coming emp id only, not name .
    Can u tell the solution as soon as possible

    Hi,
    In List Item, the First column will show in the list, and the Second column will be stored. To show both columns in list, u have to concatenate both fields and make it as first column. And i think you have to save the EMP_CODE, not EMP_NAME in database.
    So the record group will be
    SELECT EMP_ID || ' - ' || EMP_NAME EMP_NAME, EMP_ID FROM EMP WHERE MGR_ID = 100; Or you can use LOV to display multiple columns.
    Regards,
    Manu.
    If this answer is helpful or correct, please mark it. Thanks.

Maybe you are looking for

  • Launching problem

    I have problem with launching Photoshop CS6. - Error massage: You can't open the application "Adobe Photoshop CS6" because it's not supported on this type of Mac. I have no problems with Dreamweaver CS6 and InDesign CS6. (purchased products) Please h

  • JSlider

    Hello i have my JSlider workds fine i want have it fill the Track when it slides i tryed         slrSound = new JSlider(JSlider.VERTICAL,0,100,100);         slrSound.setMajorTickSpacing(10);         slrSound.setMinorTickSpacing(2);         slrSound.s

  • Table space is showing full

    Dear Experts , please clarefy me on tablespace here in my server tablespace is showing 100% full and the status is in Auto turn off mode can i increase this tablespace or no need to increase table name     size            Free   used   Auto Ext  Tota

  • Export events from iPhoto '09 into iPhoto '11

    I'm trying to take my photo library from '09 and put it into '11 on another computer. When I export all of my "Events" are gone. It places the photos into iPhoto but they aren't organized. What am I missing? TIA, Ginger

  • Mac os x 10.6.8 won't start up after kernel panic

    Hi, I got a kernel panic. When i restart the laptop the system gets stuck in the loading screen (apple logo and loading gif) with the fans spinning as if threre was no tomorrow. I tried booting in safe mode (power the comouter holding shift) but no c