Friday, November 16, 2012
Create Newline in Infopath form
"?xml version="1.0" encoding="UTF-8"?>
?characters
cr="
"
lf="
"
crlf="
"
/">
Tuesday, November 13, 2012
Call WebService using Javascript
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery.SPServices-0.6.1.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function()
{
});
//****************** Create a list item *******************//
function CreateNewItem()
{
var title=document.getElementById("txtTitle").value;
var batch =
"<Batch OnError=\"Continue\"> \
<Method ID=\"1\" Cmd=\"New\"> \
<Field Name=\"Title\">" + title + "</Field> \
</Method> \
</Batch>";
var soapEnv =
"<?xml version=\"1.0\" encoding=\"utf-8\"?> \
<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance/" \
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema/" \
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope//"> \
<soap:Body> \
<UpdateListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap//"> \
<listName>TestList</listName> \
<updates> \
" + batch + "</updates> \
</UpdateListItems> \
</soap:Body> \
</soap:Envelope>";
$.ajax({
url: "http://sharepoint.server/sites/yoursite/_vti_bin/lists.asmx",
beforeSend: function(xhr) {
xhr.setRequestHeader("SOAPAction",
"http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
},
type: "POST",
dataType: "xml",
data: soapEnv,
complete: Result,
contentType: "text/xml; charset=utf-8"
});
}
function Result(xData, status)
{
}
</script>
Sunday, October 28, 2012
Check Postback in Javascript
function isPostBack() {
return document.referrer.indexOf(document.location.href) > -1;
}
return document.referrer.indexOf(document.location.href) > -1;
}
Friday, October 26, 2012
Sharepoint people picker Validation
Sharepoint People picker validation in javascript
var validatorId = 'validator ID';
var textboxId = validatorId.replace('val_pck', 'txt_pck');
var pickerId = validatorId.replace('val_pck', 'pck');
var pickerValue = $("#" + pickerId).html();
if (pickerValue == "" || pickerValue.indexOf('title') == -1 || $("
" + pickerValue + "
").find("#divEntityData").length == 0){
alert('invalid');
}
set the value of people picker
var pickerKey = $("
"
+ pickerValue + "if (args.IsValid && $('#' + textboxId)) $('#' + textboxId).val(pickerKey);
Thursday, October 11, 2012
POST Method in XMLHTTP Request in Sharepoint
function callAjax() {
var messageContent = "Text9";
var params = "MessageContent=" + messageContent;
alert(params);
//ajax to check length
var xmlHTTPObject = new ActiveXObject("Microsoft.XMLHTTP");
if (xmlHTTPObject == null) return null;
xmlHTTPObject.Open("POST", "http://localhost:51240/WebSite1/Ajax.aspx", true);
//alert('/sites/MB/_layouts/MB2010/MBCheckMessageSize.aspx');
xmlHTTPObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// xmlHTTPObject.setRequestHeader('Content-Type', 'application/text; charset=utf-8');
xmlHTTPObject.setRequestHeader('Content-length', params.length);
///xmlHTTPObject.setRequestHeader('Connection', "close");
//alert("/_layouts/AMAT.MOLDS/GetMoldPartNo.aspx?MatNo="+partNumberVal);
xmlHTTPObject.onreadystatechange = function () {
if (xmlHTTPObject.readyState == 4 && xmlHTTPObject.status == 200) {
// alert(a.responseText);
if (xmlHTTPObject.responseText.length > 0) {
alert(xmlHTTPObject.responseText);
}
else {
//alert("Else Block");
}
}
}
//alert(d);
xmlHTTPObject.Send(params);
}
CS Page Code
Request.Form["MessageContent"];
var messageContent = "Text9";
var params = "MessageContent=" + messageContent;
alert(params);
//ajax to check length
var xmlHTTPObject = new ActiveXObject("Microsoft.XMLHTTP");
if (xmlHTTPObject == null) return null;
xmlHTTPObject.Open("POST", "http://localhost:51240/WebSite1/Ajax.aspx", true);
//alert('/sites/MB/_layouts/MB2010/MBCheckMessageSize.aspx');
xmlHTTPObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// xmlHTTPObject.setRequestHeader('Content-Type', 'application/text; charset=utf-8');
xmlHTTPObject.setRequestHeader('Content-length', params.length);
///xmlHTTPObject.setRequestHeader('Connection', "close");
//alert("/_layouts/AMAT.MOLDS/GetMoldPartNo.aspx?MatNo="+partNumberVal);
xmlHTTPObject.onreadystatechange = function () {
if (xmlHTTPObject.readyState == 4 && xmlHTTPObject.status == 200) {
// alert(a.responseText);
if (xmlHTTPObject.responseText.length > 0) {
alert(xmlHTTPObject.responseText);
}
else {
//alert("Else Block");
}
}
}
//alert(d);
xmlHTTPObject.Send(params);
}
CS Page Code
Request.Form["MessageContent"];
Thursday, August 2, 2012
Open Modal Dialog In serverside Code in sharepoint 2010
Hi,
When We will call SP.UI.ModalDialog.showModalDialog(options) in server side it will throw error "Object does not support this property" because the SP.Js will not get loaded in server side.
Solution;
Use ExecuteOrDelayUntilScriptLoaded method to avoid the error.
Javascript Function in .aspx Page
function ShowDialogTest() {
if (confirm('Do u want to continue?')) {
var modalDialog;
var urls = '<%=SPContext.Current.Web.Url %>'
urls = urls + '/_layouts/GetSPUserList/DisplayUser.aspx?caseid=' + document.getElementById('<%=hdnCase.ClientID %>').value;
var options = { showClose: true, };
var options = {
url: urls,
tite: 'Workflow Task',
allowMaximize: false,
showClose: true,
width: 800,
height: 600
};
modalDialog = SP.UI.ModalDialog.showModalDialog(options);
}
} code behind page Server side code
ScriptManager.RegisterStartupScript(this, this.GetType(), ClientID, "ExecuteOrDelayUntilScriptLoaded(ShowDialogTest, \"SP.js\");", true);
When We will call SP.UI.ModalDialog.showModalDialog(options) in server side it will throw error "Object does not support this property" because the SP.Js will not get loaded in server side.
Solution;
Use ExecuteOrDelayUntilScriptLoaded method to avoid the error.
Javascript Function in .aspx Page
function ShowDialogTest() {
if (confirm('Do u want to continue?')) {
var modalDialog;
var urls = '<%=SPContext.Current.Web.Url %>'
urls = urls + '/_layouts/GetSPUserList/DisplayUser.aspx?caseid=' + document.getElementById('<%=hdnCase.ClientID %>').value;
var options = { showClose: true, };
var options = {
url: urls,
tite: 'Workflow Task',
allowMaximize: false,
showClose: true,
width: 800,
height: 600
};
modalDialog = SP.UI.ModalDialog.showModalDialog(options);
}
} code behind page Server side code
ScriptManager.RegisterStartupScript(this, this.GetType(), ClientID, "ExecuteOrDelayUntilScriptLoaded(ShowDialogTest, \"SP.js\");", true);
Sunday, July 15, 2012
Javascript Trim and Multiple Email Validation
function trim(str) {
if (!str
typeof str != 'string')
return null;
return str.replace(/^[\s]+/, '').replace(/[\s]+$/, '').replace(/[\s]{2,}/, ' ');
}
function emails(oSrc, args) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = args.Value;
var eadrs = address.split(';');
for (i = 0; i < eadrs.length; i++) {
var adr=trim(eadrs[i]);
if (adr != "" && adr != null)
if (reg.test(adr) == false) {
args.IsValid=false;
}
}
}
ClientValidationFunction="emails" ControlToValidate="TextBox2">
if (!str
typeof str != 'string')
return null;
return str.replace(/^[\s]+/, '').replace(/[\s]+$/, '').replace(/[\s]{2,}/, ' ');
}
function emails(oSrc, args) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = args.Value;
var eadrs = address.split(';');
for (i = 0; i < eadrs.length; i++) {
var adr=trim(eadrs[i]);
if (adr != "" && adr != null)
if (reg.test(adr) == false) {
args.IsValid=false;
}
}
}
ClientValidationFunction="emails" ControlToValidate="TextBox2">
Tuesday, July 10, 2012
Clear People picker on dropdown change index in sp 2010
clearPicker()
{
var control;
var arr = document.getElementsByTagName("div");
for (var i = 0; i < arr.length; i++)
{
if (arr[i].id.indexOf("upLevelDiv") > 0)
{
control = arr[i];
}
}
control.innerHTML = '';
arr = document.getElementsByTagName("input");
for (var i = 0; i < arr.length; i++)
{
if (arr[i].name.indexOf("hiddenSpanData") > 0)
{
control = arr[i];
}
}
control.value = '';
}
Wednesday, May 30, 2012
Open new modal popup while closising the parent modal popup.
Parent page code :
var siteUrl = http://siteurl/;
var modalpage = { url: siteUrl + "/_layouts/MyModal/Pages/NewModalForms.aspx", title: "New Input Form", allowMaximize: false, width: 700, height: 300, showClose: true, dialogReturnValueCallback: silentCallback };
function openModalForm() {
SP.UI.ModalDialog.showModalDialog(modalpage);
}
function silentCallback(dialogResult, returnValue)
{
if (returnValue != null && returnValue != "")
{
OpenPopUpPageWithTitle(siteUrl + '/Lists/lst/NewForm.aspx?' + returnValue, RefreshOnDialogClose, null, null, 'New Modal Form');
}
}
Modalpopup page code
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, queryString);
var siteUrl = http://siteurl/;
var modalpage = { url: siteUrl + "/_layouts/MyModal/Pages/NewModalForms.aspx", title: "New Input Form", allowMaximize: false, width: 700, height: 300, showClose: true, dialogReturnValueCallback: silentCallback };
function openModalForm() {
SP.UI.ModalDialog.showModalDialog(modalpage);
}
function silentCallback(dialogResult, returnValue)
{
if (returnValue != null && returnValue != "")
{
OpenPopUpPageWithTitle(siteUrl + '/Lists/lst/NewForm.aspx?' + returnValue, RefreshOnDialogClose, null, null, 'New Modal Form');
}
}
Modalpopup page code
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, queryString);
Tuesday, May 22, 2012
How to Restore Deleted sitecollection in sharepoint 2010
Hi all unfortunatly i have deleted site collections in sharepoint 2010 . I am able to restored it using powerscript.
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
foreach($m in Get-SPDeletedSite)
{
Restore-SPDeletedSite -Identity $m
}
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
foreach($m in Get-SPDeletedSite)
{
Restore-SPDeletedSite -Identity $m
}
Sunday, April 8, 2012
Sharepoint Migration & Additions to this Web site have been blocked
How to Migrate MOSS 2007 to 2010
1. Take MOSS 2007 content DB backup
2. Create a DB in SQL Server and restore on it
3. Create a New Web Application in SP 2010
4. Central Admin > Manage Application >Manage Content Database > Select the specified DB
5. Select “Offline” and click on ok
6. repeat step 4 and select “Remove ContectDB “ Check Box >OK
7. Open Powershel and Use the following command
8. Mount-spcontentdatabase-Name “DBName” -WebApplication http://servername/webpallicationname
If You will get 403 error go to
Central Administration -> Application Management -> Configure Quotas and Locks
Set the Site Lock Information to "Not Lock" (it had been set to No Lock”)
1. Take MOSS 2007 content DB backup
2. Create a DB in SQL Server and restore on it
3. Create a New Web Application in SP 2010
4. Central Admin > Manage Application >Manage Content Database > Select the specified DB
5. Select “Offline” and click on ok
6. repeat step 4 and select “Remove ContectDB “ Check Box >OK
7. Open Powershel and Use the following command
8. Mount-spcontentdatabase-Name “DBName” -WebApplication http://servername/webpallicationname
If You will get 403 error go to
Central Administration -> Application Management -> Configure Quotas and Locks
Set the Site Lock Information to "Not Lock" (it had been set to No Lock”)
Subscribe to:
Posts (Atom)