Sunday, 16 September 2012

Content Editor aspx

<

script type="text/javascript">


function closefunctnProp() {


var frm = document.forms[0]; for (i = 0; i < frm.elements.length; i++) {


if (frm.elements[i].type == "checkbox") { frm.elements[i].checked = false; }


if (frm.elements[i].type == "radio")

{ frm.elements[i].checked =
false; } if (frm.elements[i].type == "text") {

frm.elements[i].value =
"";

}
if (frm.elements[i].type == "select-one")

{ frm.elements[i].value =
'--Select--'; }

}

}


function valuevisiblePropeller() {


for (i = 0; i < Page_Validators.length; i++) {

Page_Validators[i].style.visibility =
'visible';

}

}

 


function ClearpropellerTextData()

{

document.getElementById(

"<%= txtDesc.ClientID%>").value = "";

 

 


for (i = 0; i < Page_Validators.length; i++)

{

Page_Validators[i].style.visibility =

'hidden';

}


return false;

}




</script>

<

style type="text/css">


.modalBackground

{


position: absolute;


z-index: 100;


top: 0px;


left: 0px;


background-color: #000;


filter: alpha(opacity=60);


-moz-opacity: 0.6;


opacity: 0.6;

}






.menu_bg_sdprop

{


background-image: url(/_layouts/Images/VCSB/menu_bg_top.jpg);


background-position: bottom left;


background-repeat: repeat-x;


width: 222px;


height: 45px;

}




.menu_bg_sd_indprop

{


background-color: #eeeeee;


height: 230px;


width: 222px;

}


.menu_bg_sd_botProb

{


background-image:url(/_layouts/Images/VCSB/menu_bg_bot.jpg);


background-position:top left;


background-repeat: repeat-x;


width:222px;


height:20px;

}


</

style>

<

asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">

</

asp:ScriptManagerProxy>

 


<

div class="menu_bg_sdprop">


<div class="menu_left_sd">


</div>


<div class="menu_right_sd">


</div>


<div class="add_side_left">


<h4>

Propeller Studio
</h4>


</div>


<div class="add_side_right" style="direction:rtl">


<asp:ImageButton ID="ImgbtnEdit"


ImageUrl="~/_layouts/images/VCSB/Quicknote.png" runat="server" ToolTip="Edit"


OnClick="imgbtnedit_Clik" />




</div>

</

div>

 


<

div class="menu_bg_sd_indprop">


<div class="menu_left_sd_ind">


</div>


<div class="menu_right_sd_ind">


</div>




<div class="box_inner_m2">


<table>


<tr>


<td>


<div id="dv" runat="server">

</

div>


</td>


</tr>


</table>


</div>




</

div>

<

div class="menu_bg_sd_botProb">


<div class="menu_left_sd_bot">


</div>


<div class="menu_right_sd_bot">


</div>


</div>

 


<

div id="propellerdiv" class="" style="display:none;">

<

asp:Panel ID="Pnlpropellerdiv" runat="server" DefaultButton="imgbtnPropellerUpdate">


<table cellpadding="0" cellspacing="0" width="500px" border="0">


<tr>


<td class="popup1">


<table width="100%" border="0" cellpadding="0" cellspacing="0">


<tr>


<td>


<table width="100%" border="0" cellpadding="0" cellspacing="0">


<tr>


<td class="popup2">

HTML Source
</td>


<td class="" >


<asp:ImageButton ID="imgbtnPropellerclose" OnClientClick="javascript:closefunctnProp()" ImageAlign="Right" runat="server" Height="20px" ToolTip="Close" CausesValidation="false"


ImageUrl="/_layouts/images/VCSB/closebtn.png" />


</td>




</tr>


</table>


</td>


</tr>


<tr>


<td class="popup3" style="min-height: 150px; text-align: center; vertical-align: top">


<table align="center" style="padding-right: 40px;">


<tr>


<td align="right" style="width: 15%;padding-left:50px;" valign="top">




</td>


<td align="left" valign="top" style="padding-bottom: 10px;padding-right:10px;">


<asp:TextBox ID="txtDesc" Height="400px" Width="600px" TextMode="MultiLine" runat="server"></asp:TextBox><br />


<asp:RequiredFieldValidator ID="reqfdAnnounDesc" ValidationGroup="propeller" runat="server"


Display="Dynamic" ControlToValidate="txtDesc" ErrorMessage="Please enter the HTML Source."></asp:RequiredFieldValidator>






</td>


</tr>





<%

-- <tr>

<td>

&nbsp;

</td>

</tr>--


%>


<tr>


<td align="right" valign="top">


&nbsp;


</td>


<td align="right" valign="top">

 


<asp:ImageButton ID="imgbtnPropellerUpdate" ImageUrl="/_layouts/images/VCSB/upd2.png" runat="server" Height="23" ValidationGroup="propeller" ToolTip="Update"


Text="Update" OnClick="imgbtnPropellerUpdate_Click" OnClientClick="valuevisiblePropeller();" />


<asp:ImageButton ID="imgbtnPropellerClear" runat="server" Text="Clear"


ImageUrl="/_layouts/images/VCSB/cle2.png" ValidationGroup="propeller" Height="23"


OnClientClick="ClearpropellerTextData();"


ToolTip="Clear" /> &nbsp;


</td>


</tr>


</table>


</td>


</tr>


</table>


</td>


</tr>


</table>

 




</asp:Panel>

</

div>

<

cc1:ModalPopupExtender ID="mpupContentEdit" BackgroundCssClass="modalBackground"


TargetControlID="hdnpopup" CancelControlID="imgbtnPropellerclose" PopupControlID="propellerdiv"


runat="server">

</

cc1:ModalPopupExtender>

<

asp:HiddenField ID="hdnpopup" runat="server" />


<asp:HiddenField ID="hdn" runat="server" />




<

asp:HiddenField ID="hdnid" runat="server" />

Content Editor DL


public class ContentEditorDL

    {

        #region Update Propeller

        public static bool update(ContentEditorBL contBL)

        {

            bool update = false;

            SPSecurity.RunWithElevatedPrivileges(delegate()

            {

                using (VCSBINTRANETDataContext context = new VCSBINTRANETDataContext(SiteHelper.SiteUrl))

                {

                    var itemUpdate = (from r in context.PropellerStudioCE

                                      where r.Id == Convert.ToInt32(contBL.ID)

                                      select r).First();

 

                    itemUpdate.Description = contBL.Desc;

 

                    context.SubmitChanges();

                    update = true;

                }

            });

            return update;

        }

 

      # endregion

# region GetAllListItem

        public static object GetAllListItem(ContentEditorBL conBL)

        {

            string oDesc = null;

            SPSecurity.RunWithElevatedPrivileges(delegate()

            {

 

                SPSite spsite = SPContext.Current.Site;

                SPWeb spWeb = spsite.OpenWeb();

                SPList spList = spWeb.Lists["PropellerStudioCE"];

                SPListItemCollection spListItems = spList.Items;

 

 

                foreach (SPListItem ospListItemCourse in spListItems)

                {

                    oDesc = ospListItemCourse["Description"].ToString();

 

                }

 

            });

            if (oDesc != null)

            {

 

                return conBL.Desc = oDesc;

            }

            else

            {

 

                return conBL.Desc = "There is no item to show.";

 

            }

        }

        # endregion

#region GetSingleRowListItem

        public static System.Data.DataTable GetSingleRowListItem(ContentEditorBL conBL)

        {

 

            DataTable dt = new DataTable();

            //dt.Columns.Add("ID");

 

            dt.Columns.Add("Description");

 

 

            DataRow row;

            SPSecurity.RunWithElevatedPrivileges(delegate()

            {

 

                using (VCSBINTRANETDataContext context = new VCSBINTRANETDataContext(SiteHelper.SiteUrl))

                {

                    var quer = from PropeelerStudioCE in context.PropellerStudioCE

                               select PropeelerStudioCE;

 

                    if (quer != null)

                    {

                        foreach (PropellerStudioCEItem item in quer)

                        {

 

                            conBL.ID = Convert.ToInt32(item.Id);

                            conBL.Desc = Convert.ToString(item.Description);

                        }

                    }

                }

            });

            return dt;

 

        }

        #endregion

}

Content Editor BL


public class ContentEditorBL

    {

        # region Fields

        string _title = string.Empty;

        string _desc;

             

        int _listId;

        int _ContenteditorID;

 

       

 

        # endregion

       

        # region Properties

 

        public int ID

        {

            get { return _listId; }

            set { _listId = value; }

        }

        public int ContenteditorID

        {

            get { return _ContenteditorID; }

            set { _ContenteditorID = value; }

        }

 

        public string Desc

        {

            get { return _desc; }

            set { _desc = value; }

        }

 

        public string Title

        {

            get

            {

                return _title;

            }

            set

            {

                _title = value;

            }

        }

        # endregion

               

        # region Constructor

             public ContentEditorBL()

        {

 

        }

        public ContentEditorBL(int listId)

        {

            this.ID = listId;

        }

 

        public ContentEditorBL(int contenteditorid, string desc)

        {

            this.ID = contenteditorid;

            this.Desc = desc;

        }

# endregion

 

 

 

        # region Methods

 

        public bool update()

        {

            return ContentEditorDL.update(this);

        }

 

        public bool updateCE()

 

        public System.Data.DataTable GetSingleRowListItem()

        {

            return ContentEditorDL.GetSingleRowListItem(this);

        }

        public void GetAllListItem()

        {

            ContentEditorDL.GetAllListItem(this);

        }

 

        # endregion

    }

 

SharePoint online - Get List-item attachments and Display to div

Step 1 : Create a List ex: TestList and attach few images Step 2 : Copy and Pastet the below coding in App.js var  Items =  null ; ...