Search This Blog

Thursday, March 12, 2015

WevPart For Employee Registration Form

















<%@ 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="EmployeeRegitrationUserControl.ascx.cs" Inherits="EUDGridView.EmployeeRegitration.EmployeeRegitrationUserControl" %>
<table id="Submit">
<tr>
<td>Employee Name </td>
<td>
    <asp:TextBox ID="txtEmployeeName" runat="server"></asp:TextBox>
    </td>
</tr>
<tr>
<td>
    <p>
        Designation</p>
    </td>
<td>
    <asp:TextBox ID="txtDesi" runat="server"></asp:TextBox>
    </td>
</tr>

<tr>
<td>EmpID</td>
<td>
    <asp:TextBox ID="txtEmployeeID" runat="server"
       ></asp:TextBox>   </td>
</tr>

<tr>
<td>
    <asp:Button ID="btnSubmit" runat="server"
Text="Submit" onclick="btnSubmit_Click" />
    </td>
<td>
    <asp:Button ID="btnCancel" runat="server"
Text="Cancel" onclick="btnCancel_Click" />
    </td>
</tr>
</table>

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
namespace EUDGridView.EmployeeRegitration
{
    public partial class EmployeeRegitrationUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            try
            {
                txtEmployeeName.Text = String.Empty;
                txtDesi.Text = String.Empty;
                txtEmployeeID.Text = String.Empty;
            }
            catch (Exception ex)
            {
            }

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            try
            {
                SPSite mysite = SPContext.Current.Site;
                SPWeb myweb = mysite.OpenWeb();
                SPListItemCollection listItemsCol = myweb.Lists["Employee_Details"].Items;
                SPListItem item = listItemsCol.Add();
                item["EmployeeName"] = txtEmployeeName.Text;
                item["Title"] = txtDesi.Text;
                item["EmployeeID"] = Convert.ToInt32(txtEmployeeID.Text);

                item.Update();
                txtEmployeeName.Text = String.Empty;
                txtDesi.Text = String.Empty;
                txtEmployeeID.Text = String.Empty;
            }
            catch (Exception ex)
            {
            }
          
        }
    }
}




No comments:

Post a Comment