Sunday, 16 September 2012

Content Editor aspx.cs

public

partial class PropellerStudioCEUserControl :BasePage

{


protected void Page_Load(object sender, EventArgs e)

{


if (!IsPostBack)

{


if (IsSuperAdmin || IsAdmin || IsManager)

{

Bind();

}


else

{

ImgbtnEdit.Visible =

false;

Bind();

}

}

 

 

}




# region

Edit


protected void imgbtnedit_Clik(object sender, ImageClickEventArgs e)

{


ContentEditorBL conBL = new ContentEditorBL();

conBL.GetSingleRowListItem();


string oDesc = null;


SPSite oSPSiteCollection = SPContext.Current.Site;


SPWeb oSPWeb = SPContext.Current.Web;


SPList oSPList1 = oSPWeb.Lists["PropellerStudioCE"];


SPListItemCollection oItemCollectionCourse = oSPList1.Items;


foreach (SPListItem ospListItemCourse in oItemCollectionCourse)

{

oDesc = ospListItemCourse[

"Description"].ToString();

txtDesc.Text = conBL.Desc;


// txtDesc.Text = SPHttpUtility.ConvertSimpleHtmlToText(oDesc, oDesc.Length);

hdnid.Value =
Convert.ToString(conBL.ID);

}

mpupContentEdit.Show();


StringBuilder sb = new StringBuilder();

sb.Append(
"<script type=\"text/javascript\">\n");

sb.Append(
"Sys.Application.add_load(modalSetup);\n");

sb.Append(
"function modalSetup() {\n");

sb.Append(
String.Format("var modalPopup = $find('{0}');\n", mpupContentEdit.BehaviorID));

sb.Append(
"modalPopup.add_shown(SetFocusOnControl); }\n");

sb.Append(
"function SetFocusOnControl() {\n");

sb.Append(
String.Format("var textBox1 = $get('{0}');\n", txtDesc.ClientID));

sb.Append(
"textBox1.focus();}\n");

sb.Append(
"</script>\n");

Page.ClientScript.RegisterStartupScript(Page.GetType(),
"Startup", sb.ToString());

}


# endregion



# region

Bind


private void Bind()

{


ContentEditorBL ConBL = new ContentEditorBL();

ConBL.GetAllListItem();

dv.InnerHtml = ConBL.Desc;

}


# endregion

# region


Update


protected void imgbtnPropellerUpdate_Click(object sender, EventArgs e)

{


if (!string.IsNullOrEmpty(txtDesc.Text))

{


ContentEditorBL conBL = new ContentEditorBL(Convert.ToInt32(hdnid.Value),txtDesc.Text);

 


if (conBL.update())

{

Bind();

}

mpupContentEdit.Hide();

}

}


# endregion



}

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" />

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 ; ...