Monday, 18 June 2012

DL(DAL)

STEP 1: Create a class file like QuickLinksDL.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using VCSB.INTRANET.BLL;
using Microsoft.SharePoint;

namespace VCSB.INTRANET.DAL
{
   public class QuickLinksDL
    {
       public static bool update(QuickLinksBL quickLinksBL)
       {

           bool update = false;
           SPSecurity.RunWithElevatedPrivileges(delegate()
           {
               using (VCSBINTRANETDataContext datacontxt = new VCSBINTRANETDataContext(SiteHelper.SiteUrl))
               {


                   var itemUpdate = (from updateequery in datacontxt.QuickLinks
                                     where updateequery.Id == Convert.ToInt32(quickLinksBL.ID)
                                     select updateequery).First();

                   itemUpdate.Title = quickLinksBL.Quicktitle;
                   itemUpdate.Url = quickLinksBL.Quickurl;
                   datacontxt.SubmitChanges();
               }
               update = true;
           });

           return update;
       }
       public static System.Data.DataTable GetAllListItem(QuickLinksBL quickLinksBL)
       {
           DataTable dt = new DataTable();
           dt.Columns.Add("ID");
           dt.Columns.Add("Title");
           dt.Columns.Add("Url");

           DataRow row;
           SPSecurity.RunWithElevatedPrivileges(delegate()
           {
               using (VCSBINTRANETDataContext context = new VCSBINTRANETDataContext(SiteHelper.SiteUrl))
               {
                   var quer = from quicklinksData in context.QuickLinks
                              orderby quicklinksData.Id descending
                              select quicklinksData;

                   if (quer != null)
                   {
                       foreach (QuickLinksItem item in quer)
                       {
                           row = dt.Rows.Add();
                           row["ID"] = Convert.ToString(item.Id);
                           row["Title"] = Convert.ToString(item.Title);
                           row["Url"] = Convert.ToString(item.Url);
                       }
                   }
               }
           });
           return dt;
       }
       public static System.Data.DataTable GetSingleRowListItem(QuickLinksBL quickLinksBL)
       {

           DataTable dt = new DataTable();
           dt.Columns.Add("ID");
           dt.Columns.Add("Title");
           dt.Columns.Add("Url");
           DataRow row;
           SPSecurity.RunWithElevatedPrivileges(delegate()
           {
               using (VCSBINTRANETDataContext context = new VCSBINTRANETDataContext(SiteHelper.SiteUrl))
               {
                   var quer = from quicklinksData in context.QuickLinks
                              where quicklinksData.Id == quickLinksBL.ID
                              select quicklinksData;

                   if (quer != null)
                   {
                       foreach (QuickLinksItem item in quer)
                       {
                           row = dt.NewRow();
                           row["ID"] = Convert.ToString(item.Id);
                           row["Title"] = Convert.ToString(item.Title);
                           row["Url"] = Convert.ToString(item.Url);
                           dt.Rows.Add(row);

                       }
                   }
               }
           });
           return dt;
       }
    }
}


BL(BLL)

STEP 1: Create the class file like QuickLinksBL.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VCSB.INTRANET.DAL;

namespace VCSB.INTRANET.BLL
{

  public class QuickLinksBL:IVCSBIntranetBL
  {


      # region Fields & Properties
      int _listId;

        string _title = string.Empty, _quickurl = string.Empty;
        string _quicktitle;

        public string Quicktitle
        {
            get { return _quicktitle; }
            set { _quicktitle = value; }
        }
        public string Quickurl
        {
            get { return _quickurl; }
            set { _quickurl = value; }
        }
       
        public int ID
        {
            get { return _listId; }
            set { _listId = value; }
        }

        public string Title
        {
            get
            {
                return _title;
            }
            set
            {
                _title = value;
            }
        }

      # endregion

        #region Constructor
        public QuickLinksBL()
        {


        }
        public QuickLinksBL(int listId)
        {
            this.ID = listId;
        }
        public QuickLinksBL(int quicklinksID, string quicklinkstitle, string quicklinksurl)
        {
            this.ID = quicklinksID;
            this.Quicktitle = quicklinkstitle;
            this.Quickurl = quicklinksurl;
           
        }
        # endregion

        # region Methods
        public bool insert()
        {
            throw new NotImplementedException();
        }

        public bool update()
        {
          return QuickLinksDL.update(this);

        }

        public bool delete()
        {
            throw new NotImplementedException();
        }

        public System.Data.DataTable GetAllListItem()
        {
            return QuickLinksDL.GetAllListItem(this);
        }

        public void GetSingleRowListItem(int id)
        {
            throw new NotImplementedException();
        }
        public System.Data.DataTable GetSingleRowListItem()
        {
          return QuickLinksDL.GetSingleRowListItem(this);
        }
        # endregion
  }

}

Monday, 4 June 2012

BasePage(ascx.cs)

STEP 1: Create a VisualWebpart like BasePageWP

STEP 2:

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using VCSB.INTRANET.BLL;
using System.Web;
using Microsoft.SharePoint;
using System.Xml;

namespace VCSB01.INTRANET.VCSBWebPart.BasePageWP
{
    public partial class BasePageWPUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
            if (!IsPostBack)
            {

                BasePage chkuser = new BasePage();

                if (SiteHelper.CurrentUserLoginName() != "NA")
                {

                    if (Session["GroupID"] == null)
                    {
                        if (SiteHelper.IsSiteAdmin())
                        {
                            HttpContext.Current.Session["GroupID"] = ((int)RoleType.SuperAdmin).ToString();

                        }
                        else
                        {
                            if (SiteHelper.CurrentUserRoleType() == SPRoleType.Administrator.ToString())
                            {
                                HttpContext.Current.Session["GroupID"] = ((int)RoleType.OwnerGroup).ToString();
                            }
                            if (SiteHelper.CurrentUserRoleType() == SPRoleType.Contributor.ToString())
                            {
                                HttpContext.Current.Session["GroupID"] = ((int)RoleType.MemeberGroup).ToString();
                            }
                            if (SiteHelper.CurrentUserRoleType() == SPRoleType.Reader.ToString())
                            {
                                HttpContext.Current.Session["GroupID"] = ((int)RoleType.VisitorGroup).ToString();
                            }
                        }
                    }
                    else
                    {
                        chkuser.CheckUser();
                        if (chkuser.IsSuperAdmin)
                        {

                        }
                        else if (chkuser.IsAdmin)
                        {

                        }
                        else if (chkuser.IsManager)
                        {

                        }
                        else if (chkuser.IsEndUser)
                        {

                        }
                        else
                        {

                        }
                    }

                }
                else
                {

                    //no user                     
                }


            }
        }
    }
}

BasePage(BL)

 STEP 1: Create a Class file like BasePage.cs (Used for find the user level)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Web;
namespace VCSB.INTRANET.BLL
{
    public class BasePage : System.Web.UI.UserControl
    {
        #region Fields
        bool _isSuperAdmin, _IsAdmin, _isManager, _IsEndUser = false;

      
        #endregion

        #region Properties

        public bool IsEndUser
        {
            get { return _IsEndUser; }
            set { _IsEndUser = value; }
        }

        public bool IsManager
        {
            get { return _isManager; }
            set { _isManager = value; }
        }

        public bool IsAdmin
        {
            get { return _IsAdmin; }
            set { _IsAdmin = value; }
        }

        public bool IsSuperAdmin
        {
            get { return _isSuperAdmin; }
            set { _isSuperAdmin = value; }
        }
      

      
        #endregion

        #region Methods
      
        protected override void OnLoad(EventArgs e)
        {
            CheckUser();
            base.OnLoad(e);
        }  

      
        public void CheckUser()
        {
            if (HttpContext.Current.Session.Count > 0)
            {
                if (!string.IsNullOrEmpty(Convert.ToString(HttpContext.Current.Session["GroupID"])))
                {
                    int i = Convert.ToInt32(HttpContext.Current.Session["GroupID"].ToString());
                    switch (i)
                    {
                        case (int)RoleType.SuperAdmin:
                            IsSuperAdmin = true; break;
                        case (int)RoleType.OwnerGroup:
                            IsAdmin = true;
                            break;
                        case (int)RoleType.MemeberGroup:
                            IsManager = true;
                            break;
                        case (int)RoleType.VisitorGroup:
                            IsEndUser = true;
                            break;                     
                        default: IsAdmin = IsManager = IsEndUser = false;
                            break;
                    }
                }
            }

        }

        #endregion

    }

    #region Enum
    public enum RoleType
    {
        SuperAdmin,
        OwnerGroup,
        MemeberGroup,
        VisitorGroup,       
    }
  
    #endregion
}

ASCX(.ascx)

STEP 1: Create a VisualWebPart like NewsAndArticlesReadMore

STEP 2: Write a coding in NewsAndArticlesReadMoreUserControl.ascx


STEP 3:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="NewsAndArticlesReadMoreUserControl.ascx.cs" Inherits="VCSB01.INTRANET.WebPartDetailsPage.NewsAndArticlesReadMore.NewsAndArticlesReadMoreUserControl" %>
 <%@ Register Assembly="AjaxControlToolkit, Version=3.0.30512.20315, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"
    Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

 <link href="/_layouts/Styles/VCSB/style.css" rel="stylesheet" type="text/css" />
    <link href="/_layouts/Styles/VCSB/Blog.css" rel="stylesheet" type="text/css" />
   
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

    <script type="text/javascript">
        function hidecontrolSubmit(subm) {
            $('#<%=btnSubmit.ClientID %>').hide();
            $('#<%=btnUpdate.ClientID %>').show();
        }
        function hidecontrolUpdate(upt) {
            $('#<%=btnSubmit.ClientID %>').show();
            $('#<%=btnUpdate.ClientID %>').hide();
        }

    </script>
<script type="text/javascript">

    function SelectAllCheckboxes(chk) {
      
        $('#<%=grdNewsAndArticleAll.ClientID %>').find("input:checkbox").each(function () {
            if (this != chk) {
                this.checked = chk.checked;

            }
            if (this.checked == true) {

                $('#<%=imgbtnEdit.ClientID %>').attr('disabled', 'disabled');
                $('#<%=imgbtnAdd.ClientID %>').attr('disabled', 'disabled');

            }
            else {
                $('#<%=imgbtnEdit.ClientID %>').removeAttr('disabled');
                $('#<%=imgbtnAdd.ClientID %>').removeAttr('disabled');

            }
        });

    }
    function CheckboxCount(chkcount) {
      
        var gridView1Control = $('#<%=grdNewsAndArticleAll.ClientID %>');
        //To uncheck the header checkbox when there are no selected checkboxes in itemtemplate
        var count = 0;
        $('input:checkbox[id$=chkSelect]:checked', gridView1Control).each(function (item, index) {
            count = count + 1;
        });
        if (count > 1) {
            $('#<%=imgbtnAdd.ClientID %>').attr('disabled', 'disabled');
            $('#<%=imgbtnEdit.ClientID %>').attr('disabled', 'disabled');
            $('#<%=imgbtnDelete.ClientID %>').removeAttr('disabled');
        }
        else if (count == 1) {
            $('#<%=imgbtnAdd.ClientID %>').attr('disabled', 'disabled');
            $('#<%=imgbtnEdit.ClientID %>').removeAttr('disabled');
            $('#<%=imgbtnDelete.ClientID %>').removeAttr('disabled');
        }
        else {
            $('#<%=imgbtnEdit.ClientID %>').attr('disabled', 'disabled');
            $('#<%=imgbtnDelete.ClientID %>').attr('disabled', 'disabled');
            $('#<%=imgbtnAdd.ClientID %>').removeAttr('disabled');
        }
    }

</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;
}


</style>
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</asp:ScriptManagerProxy>



    <!--content  outer part open-->
    <div class="main_box_content">
     <div class="main_box">
                <div class="main_box_left">
                </div>
                <div class="main_box_bg">
                </div>
                <div class="main_box_right">
                </div>
                <div class="clear">
                </div>
            </div>
            <div class="main_box_bg_mid">

    <div class="content_inner" >

    <div class="first_part">
                        <div class="info">
                            <div class="infogry_left"></div>
                          <div class="info_bg"><h7>News And Articles</h7></div>
                            <div dir="rtl" style="padding-top:7px"><asp:ImageButton ID="imgbtnDelete"
                                    runat="server" Width="54" Height="21" hspace="4" ImageAlign="Right" 
                                    ImageUrl="/_layouts/Images/VCSB/btn_delete.jpg" onclick="imgbtnDelete_Click" />                                
                    <asp:ImageButton ID="imgbtnEdit" runat="server" Width="41" Height="21" align=""
                                    ImageAlign="Right" ImageUrl="/_layouts/Images/VCSB/btn_edit.jpg" onclick="imgbtnEdit_Click" />
                    <asp:ImageButton ID="imgbtnAdd" runat="server" Width="41" Height="21" align=""
                                    ImageAlign="Right" OnClientClick="javascript:hidecontrolUpdate();"
                                    ImageUrl="/_layouts/Images/VCSB/btn_add.jpg" /></div>
                        </div>
                       
                        <div class="clear">
                        </div>
                    </div>
       
   

    <div class="bor_box" >
                         <div class="bor_box_inner">
                       
                        <div class="box_inn_left"></div>
                      
                             <table width="100%">
                                 <tr>
                                     <td width="100%">
                                    
                                         <SharePoint:SPGridView ID="grdNewsAndArticleAll" Width="100%" runat="server" BorderStyle="None"
                                             AutoGenerateColumns="False" GridLines="None" ShowHeader="true" AllowSorting="true" OnSorting="grdNewsAndArticleAllDetails_Sorting">
                                             <Columns>
                                                 <asp:TemplateField>
                                                     <HeaderTemplate>
                                                         <asp:CheckBox ID="chkSelectAll" runat="server" ToolTip="Select All" onclick="javascript:SelectAllCheckboxes(this);" />
                                                     </HeaderTemplate>
                                                     <HeaderStyle Height="30px" />
                                                     <ItemTemplate>
                                                         <asp:CheckBox ID="chkSelect" Text="" onclick="javascript:CheckboxCount(this);" runat="server" />
                                                         <asp:HiddenField ID="hdnNewsAndArticle" Value='<%#DataBinder.Eval(Container.DataItem, "ID") %>' runat="server" />
                                                     </ItemTemplate>
                                                     <ItemStyle Width="7%" VerticalAlign="Top" HorizontalAlign="Center" />
                                                 </asp:TemplateField>
                                                 <asp:TemplateField  HeaderText="News And Articles Title" SortExpression="NewsTitle">
                                                     <ItemStyle />
                                                     <ItemTemplate>
                                                         <table width="100%">
                                                             <tr>
                                                                 <td width="100%">
                                                                     <%# Eval("NewsTitle")%>
                                                                     -
                                                                     <%# Eval("NewsDate") %>
                                                                 </td>
                                                             </tr>
                                                             <tr>
                                                                 <td width="100%">
                                                                     <div class="box_inn_mid2">
                                                                         <%# Eval("NewsDescription")%>
                                                                     </div>
                                                                 </td>
                                                             </tr>
                                                         </table>
                                                     </ItemTemplate>
                                                     <ItemStyle VerticalAlign="Top" />
                                                 </asp:TemplateField>
                                                 <asp:TemplateField HeaderText="News And Articles Image" SortExpression="NewsImage">
                                                     <ItemStyle />
                                                     <ItemTemplate>
                                                         <div class="box_inn_right2">
                                                             <asp:Image ID="imgNewsImage" ImageUrl='<%# Eval("NewsImage") %>' Height="150px" runat="server" />
                                                         </div>
                                                     </ItemTemplate>
                                                 </asp:TemplateField>
                                             </Columns>
                                         </SharePoint:SPGridView>
                                          
                                         &nbsp;
                                     </td>
                                 </tr>
                             </table>
                                   
                      
                         <div class="clear">
                        </div>
           </div>
        </div>

</div>
</div>
<div class="main_box1">
                <div class="main_box_bot_left">
                </div>
                <div class="main_box_bot_bg">
                </div>
                <div class="main_box_bot_right">
                </div>
                <div class="clear">
                </div>
            </div>
</div>
 

          
<div id="newsdiv" class="bg_pop_up" style="display:none;" >
 <table width="100%" align="center" border="0" cellspacing="0" cellpadding="5" >
  <tr style="height:40px;">
    <td colspan="2" class="bg_pop_uphead">&nbsp;News And Articles</td>
    <td class="bg_pop_uphead">
        <asp:ImageButton ID="imgbtnClose" ImageUrl="/_layouts/images/VCSB/closebtn.png" Height="20px" runat="server"/> </td>
    </tr> 
  <tr>
    <td align="right" valign="top">Title</td>
    <td align="left" valign="top">
        <asp:TextBox ID="txtTitle" runat="server" Width="280px" ></asp:TextBox>
        </td>
  </tr>
  <tr>
    <td align="right" valign="top">Description</td>
    <td align="left" valign="top">
     <asp:TextBox ID="txtDescription" runat="server"  Columns="35" Rows="5"
            TextMode="MultiLine"></asp:TextBox>
  </td>

  </tr>
  <tr>
    <td align="right" valign="top">NewsAndArticleDate</td>
    <td align="left" valign="top">
     <asp:TextBox ID="txtArticleDate" runat="server" Width="130px"></asp:TextBox>
        <cc1:CalendarExtender ID="calexArticalDate" TargetControlID="txtArticleDate" runat="server">
        </cc1:CalendarExtender>

   </td>

  </tr>
  <tr>
    <td align="right" valign="top">Upload Image</td>
    <td align="left" valign="top">
        <asp:FileUpload ID="fldNewsImage"  runat="server" />   
    </td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">
        <asp:Button ID="btnSubmit" runat="server" CssClass="bg_pop_up_btn"
            Text="Submit" onclick="btnSubmit_Click" />
            <asp:Button ID="btnUpdate" runat="server" CssClass="bg_pop_up_btn"
            Text="Update" onclick="btnUpdate_Click" />
        <asp:Button ID="imgbtnClear" runat="server" CssClass="bg_pop_up_btn" Text="Clear" />    
          
    </td>

  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">
      &nbsp;
   </td>
  </tr>
</table>
</div>

<cc1:ModalPopupExtender ID="mpupNewsAndArticlesAdd" TargetControlID="imgbtnAdd" BackgroundCssClass="modalBackground" PopupControlID="newsdiv" CancelControlID="imgbtnClose" PopupDragHandleControlID="header" runat="server">
</cc1:ModalPopupExtender>

<cc1:ModalPopupExtender ID="mpupNewsAndArticlesEdit" TargetControlID="hdnpopup" BackgroundCssClass="modalBackground" PopupControlID="newsdiv" CancelControlID="imgbtnClose" PopupDragHandleControlID="header"  runat="server">
</cc1:ModalPopupExtender>

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

ASCX.CS(.ascx.cs)

STEP 1: Create a VisualWebPart like NewsAndArticlesReadMore

STEP 2: Write a coding in NewsAndArticlesReadMoreUserControl.ascx


STEP 3:


using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using VCSB.INTRANET.BLL;
using System.Data;

namespace VCSB01.INTRANET.WebPartDetailsPage.NewsAndArticlesReadMore
{
    public partial class NewsAndArticlesReadMoreUserControl : BasePage
    {
        string moreId,moreid1;
        protected void Page_Load(object sender, EventArgs e)
        {
             moreId =Convert.ToString(Request.QueryString["moreId"]);
             Session.Add(moreid1, moreId);

            if (!IsPostBack)
            {
                if (IsSuperAdmin || IsAdmin || IsManager)
                {
                    imgbtnAdd.Visible = true;
                    imgbtnEdit.Visible = true;
                    imgbtnDelete.Visible = true;

                }
               if(IsEndUser)
                {
                    imgbtnAdd.Visible = false;
                    imgbtnEdit.Visible = false;
                    imgbtnDelete.Visible = false;

                }

                if (!string.IsNullOrEmpty(moreId) || !string.IsNullOrEmpty(moreid1))
                    {
                      
                        NewsAndArticlesSingleRow();
                    }
                    else
                    {
                     
                        NewsAndArticlesAll();
                    }
                //}
               
            }
        }

        public void NewsAndArticlesSingleRow()
        {
           
            NewsAndArticlesBL newsAndArticlesSingleRow = new NewsAndArticlesBL(Convert.ToInt32(moreId));
            grdNewsAndArticleAll.DataSource = newsAndArticlesSingleRow.GetSingleRowListItem();
            grdNewsAndArticleAll.DataBind();

        }

        public void NewsAndArticlesAll()
        {
            NewsAndArticlesBL newsAndArticlesAll = new NewsAndArticlesBL();
            grdNewsAndArticleAll.DataSource = newsAndArticlesAll.GetAllListItem();
            grdNewsAndArticleAll.DataBind();
            Session["TaskTable"] = newsAndArticlesAll.GetAllListItem();
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
          
            foreach (GridViewRow di in grdNewsAndArticleAll.Rows)
            {
                CheckBox chkBx = (CheckBox)di.FindControl("chkSelect");

                HiddenField htnobj = (HiddenField)di.FindControl("hdnNewsAndArticle");
                if (chkBx.Checked)
                {
                    NewsAndArticlesBL newsAndArticlesBL = new NewsAndArticlesBL(Convert.ToInt32(htnobj.Value), txtTitle.Text, txtDescription.Text, Convert.ToDateTime(txtArticleDate.Text), fldNewsImage);
                    if (newsAndArticlesBL.update())
                    {
                      
                    }


                }
            }
            NewsAndArticlesAll();
          
        }

        protected void imgbtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            btnSubmit.Visible = false;
           
            DataTable dt = new DataTable();
                       foreach (GridViewRow di in grdNewsAndArticleAll.Rows)
            {
                CheckBox chkBx = (CheckBox)di.FindControl("chkSelect");

                HiddenField htnobj = (HiddenField)di.FindControl("hdnNewsAndArticle");
                if (chkBx.Checked)
                {
                    NewsAndArticlesBL newsAndArticlesSingleRow = new NewsAndArticlesBL(Convert.ToInt32(htnobj.Value));
                    dt = newsAndArticlesSingleRow.GetSingleRowListItem();
                     txtTitle.Focus();
                     txtTitle.Text = Convert.ToString(dt.Rows[0]["NewsTitle"]);

                     txtArticleDate.Text = Convert.ToString(dt.Rows[0]["NewsDate"]);
                     txtDescription.Text = Convert.ToString(dt.Rows[0]["NewsDescription"]);
                     string path = Convert.ToString(dt.Rows[0]["NewsImage"]);
                   
                }
            }
            mpupNewsAndArticlesEdit.Show();
           
        }

        protected void imgbtnDelete_Click(object sender, ImageClickEventArgs e)
        {

            foreach (GridViewRow di in grdNewsAndArticleAll.Rows)
            {
                CheckBox chkBx = (CheckBox)di.FindControl("chkSelect");

                HiddenField htnobj = (HiddenField)di.FindControl("hdfPropeller");
                if (chkBx.Checked)
                {
                    NewsAndArticlesBL newsAndArticlesSingleRow = new NewsAndArticlesBL(Convert.ToInt32(htnobj.Value));

                    if (newsAndArticlesSingleRow.delete())
                    {

                        //
                    }
                }
            }
            NewsAndArticlesAll();
        }


        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtTitle.Text) && !string.IsNullOrEmpty(txtDescription.Text) && !string.IsNullOrEmpty(txtArticleDate.Text))
            {
                NewsAndArticlesBL newsAndArticlesBL = new NewsAndArticlesBL(txtTitle.Text, txtDescription.Text, Convert.ToDateTime(txtArticleDate.Text), fldNewsImage);

                if (newsAndArticlesBL.insert())
                {
                    NewsAndArticlesAll();

                    //insert success
                }
                else
                {
                    //fail
                }
            }

        }

        protected void grdNewsAndArticleAllDetails_Sorting(object sender, GridViewSortEventArgs e)
        {

            //Retrieve the table from the session object.
            DataTable dt = Session["TaskTable"] as DataTable;

            if (dt != null)
            {

                //Sort the data.
                dt.DefaultView.Sort = e.SortExpression + " " + GetSortDirection(e.SortExpression);
                grdNewsAndArticleAll.DataSource = Session["TaskTable"];
                grdNewsAndArticleAll.DataBind();

            }

        }

        private string GetSortDirection(string column)
        {

            // By default, set the sort direction to ascending.
            string sortDirection = "ASC";

            // Retrieve the last column that was sorted.
            string sortExpression = ViewState["SortExpression"] as string;

            if (sortExpression != null)
            {
                // Check if the same column is being sorted.
                // Otherwise, the default value can be returned.
                if (sortExpression == column)
                {
                    string lastDirection = ViewState["SortDirection"] as string;
                    if ((lastDirection != null) && (lastDirection == "ASC"))
                    {
                        sortDirection = "DESC";
                    }
                }
            }

            // Save new values in ViewState.
            ViewState["SortDirection"] = sortDirection;
            ViewState["SortExpression"] = column;

            return sortDirection;
        }
       
    }
}
 

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