Monday, 18 June 2012

ASCX.CS(.ascx.cs)

STEP 1: Create a VisualWebPart like QuickLinks

STEP 2: Write a coding in QuickLinksUserControl.ascx.cs 


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;
using Microsoft.SharePoint.Utilities;


namespace VCSB01.INTRANET.VCSBWebPart.QuickLinks
{
    public partial class QuickLinksUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    BindQuickLinksData();
                }
            }
            catch (Exception ex)
            {
                ErrorHelper.Add(Convert.ToString(ex.Message), Convert.ToString(ex.StackTrace));
                SPUtility.TransferToErrorPage(MessageHelper.Message(MessageMode.CommonErrorMessage));
            }
        }
        private void BindQuickLinksData()
        {
            QuickLinksBL objquickData = new QuickLinksBL();
            grdQuickLinks.DataSource = objquickData.GetAllListItem();
            grdQuickLinks.DataBind();
        }


        protected void grdQuickLinks_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            DataTable dt = new DataTable();
            hdnValue.Value = e.CommandArgument.ToString();
            if (e.CommandName == "edit")
            {
                QuickLinksBL quickLinksBL = new QuickLinksBL(Convert.ToInt32(hdnValue.Value));
                dt = quickLinksBL.GetSingleRowListItem();
                txtQuickTitle.Focus();
                txtQuickTitle.Text = Convert.ToString(dt.Rows[0]["Title"]);
                txtQuickUrl.Text = Convert.ToString(dt.Rows[0]["Url"]);
            }
           
            mpeQuickLinks.Show();
        }

        protected void btnQuickSubmit_Click1(object sender, EventArgs e)
        {
            try
            {
                string id = hdnValue.Value;
                QuickLinksBL quickLinksBL = new QuickLinksBL(Convert.ToInt32(id), txtQuickTitle.Text, txtQuickUrl.Text);
                quickLinksBL.update();
                BindQuickLinksData();
            }
            catch (Exception ex)
            {
                ErrorHelper.Add(Convert.ToString(ex.Message), Convert.ToString(ex.StackTrace));
                SPUtility.TransferToErrorPage(MessageHelper.Message(MessageMode.CommonErrorMessage));
            }
        }

        protected void grdQuickLinks_RowEditing(object sender, GridViewEditEventArgs e)
        {

        }
       
    }
}
 

No comments:

Post a Comment

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