Saturday, June 15, 2013
SharePoint 2010 farm version power shell comment
Get-spfarm | select buildversion
Lower version no problem, but higher version could't backup
Friday, June 14, 2013
Change Date Formate in Grid view
<asp:TemplateField>
Thursday, June 13, 2013
Grid View Edit & Delete
<asp:TemplateField HeaderText="Edit">
<ItemTemplate><asp:HiddenField ID="hdnedit" runat="server" Value='<%# Bind("ID") %>' /><asp:ImageButton ID="imgbtnedit" runat="server" CommandName="Edit" ToolTip="Edit"ImageUrl="/_Layouts/edit.png" /></ItemTemplate><HeaderStyle HorizontalAlign="Center" /><ItemStyle HorizontalAlign="Center" /></asp:TemplateField><asp:TemplateField HeaderText="Delete"><ItemTemplate><asp:HiddenField ID="hdndelete" runat="server" Value='<%# Bind("ID") %>' /><asp:ImageButton ID="imgbtndelete" runat="server" CommandName="Delete" ToolTip="Delete"ImageUrl="/_Layouts/delete.png" OnClientClick="Javascript:return fnDelete(this);" /></ItemTemplate></asp:TemplateField>--------------------------------------void gvform_RowEditing(object sender, GridViewEditEventArgs e){
GridViewRow gvedit = gvform.Rows[e.NewEditIndex];
Label lblidval = (Label)gvedit.FindControl("lblid");lblidvalue.Text = lblidval.Text;
try{
using (SPSite osite = new SPSite(SPContext.Current.Site.ID)){
using (SPWeb oweb = osite.OpenWeb()){
SPList olist = oweb.Lists.TryGetList("EmployeeList");
if (olist != null){
SPListItem splitem = olist.Items.GetItemById(Convert.ToInt32(lblidval.Text));txtFName.Text =
Convert.ToString(splitem["FName"]);txtLName.Text =
Convert.ToString(splitem["LName"]);txtEmpID.Text =
Convert.ToString(splitem["EmpID"]);txtEmail.Text =
Convert.ToString(splitem["MailID"]);ddjoindate.SelectedDate =
Convert.ToDateTime(splitem["JoinDate"]);dddob.SelectedDate =
Convert.ToDateTime(splitem["DOB"]);dddepartment.SelectedIndex =
Convert.ToInt32(splitem["Dept"]); // dropdown Bind_Data();
}
-----------------------
DELETING
(Get ID from gridview)
void gvform_RowDeleting(object sender, GridViewDeleteEventArgs e){
try{
GridViewRow gvrow = gvform.Rows[e.RowIndex];
Label lblid = (Label)gvrow.FindControl("lblid");
int deleteval = Convert.ToInt32(lblid.Text);Deleted_Action_Details(deleteval);
}
catch (Exception ex){
throw ex;}
}
---------
(Assign the ID)
void Deleted_Action_Details(int val){
try{
using (SPSite osite = new SPSite(SPContext.Current.Site.ID)){
using (SPWeb oweb = osite.OpenWeb()){
SPList olist = oweb.Lists.TryGetList("EmployeeList");
if (olist != null){
SPListItem splitem = olist.Items.GetItemById(val);oweb.AllowUnsafeUpdates =
true;splitem.Delete();
oweb.AllowUnsafeUpdates =
false;Bind_Data();
}
}
}
Bind_Data();
}
catch (Exception ex){
throw ex;}
}
Application Page JavaScript Validation For all Controls
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="return validationfrm();" />
-------------------------------------------<script type="text/javascript">function validationfrm() {
var rval = true;
var objfoucs;
var varFName = document.getElementById('<%=txtFName.ClientID %>').value;
var varLName = document.getElementById('<%=txtLName.ClientID %>').value;
var varEmpID = document.getElementById('<%=txtEmpID.ClientID %>').value;
var varEmail = document.getElementById('<%=txtEmail.ClientID %>').value;
var varddjoindate = document.getElementById('<%=ddjoindate.Controls[0].ClientID %>').value;
var vardob = document.getElementById('<%=dddob.Controls[0].ClientID %>').value;
var varppmanager = document.getElementById('<%=ppmanager.ClientID %>').value;
if (varFName == null || varFName == "") {alert(
"First name must be filled out");
if (objfoucs == null)objfoucs = document.getElementById(
'<%=txtFName.ClientID %>');objfoucs.focus();
rval =
false;}
else if (varLName == null || varLName == "") {alert(
"Last name must be filled out");
if (objfoucs == null)objfoucs = document.getElementById(
'<%=txtLName.ClientID %>');objfoucs.focus();
rval =
false;}
else if (varEmpID == null || varEmpID == "") {alert(
"Employee ID must be filled out");
if (objfoucs == null)objfoucs = document.getElementById(
'<%=txtEmpID.ClientID %>');objfoucs.focus();
rval =
false;}
else if (varEmail == null || varEmail == "") {alert(
"Email must be filled out");
if (objfoucs == null)objfoucs = document.getElementById(
'<%=txtEmail.ClientID %>');objfoucs.focus();
rval =
false;}
else if (varddjoindate == "") {alert(
"Date Of Join must be filled out");
if (objfoucs == null)objfoucs = document.getElementById(
'<%=ddjoindate.Controls[0].ClientID %>');objfoucs.focus();
rval =
false;}
else if (vardob == "") {alert(
"Date Of Birth must be filled out");
if (objfoucs == null)objfoucs = document.getElementById(
'<%=dddob.Controls[0].ClientID %>');objfoucs.focus();
rval =
false;}
else if (varppmanager == "") {alert(
"Please Pick Your Manager");
if (objfoucs == null)objfoucs = document.getElementById(
'<%=ppmanager.ClientID %>');objfoucs.focus();
rval =
false;}
//alert(rval);return rval;
}
</script><script language="javascript" type="text/javascript">function fnDelete(obj) {
if (confirm("Are you sure you want to delete?")) {
return true;}
elsereturn false;}
</script>
Subscribe to:
Posts (Atom)