Friday, December 31, 2010

Register Javascript using SharePoint Feature

You can register JavaScript and CSS without change your SharePoint sites master page.Follow below steps to register JavaScript in master page.

  • Open VS 2010 & create one blank SharePoint 2010 Project.

  • Then Add New Item & select SharePoint 2010’s “Empty Element” and give name “JQueryRegisterElement” as below.

  • Then right click on project and add “SharePoint Mapped Folder” & select “Control Templates” as below.Then add one Usercontrol in this Control Templates folder.

  • Now open Element.xml and add below code for register JavaScript.










Then open UserControl



  • Then Right click on project, Deploy it & open SharePoint Site. You will see below popup.

Happy Coding !!!

Thursday, December 30, 2010

Kill Office Application programmatically

You can kill particular application from multiple applications.
Means create multiple application objects and try to kill it will destroy particular process.
Ex. Create multiple office word document programmatically so every time you open this application one process will create in Task Manager “Word.exe” so after some limited document open your PC will hang.
Due to this I added below code for remove completed process from PC as below code.



Hashtable myHashtable = null;
protected void btn_Click(object sender, EventArgs e)
{
// get process ids before running the excel codes
CheckCurrentApplicationProcesses();

//your code for open application like Word,Excel,Access etc....

KillApplication();

}

private void CheckCurrentApplicationProcesses()
{
Process[] AllProcesses = Process.GetProcessesByName("ApplicationName");
myHashtable = new Hashtable();
int iCount = 0;

foreach (Process ApplicationProcess in AllProcesses)
{
myHashtable.Add(ApplicationProcess.Id, iCount);
iCount = iCount + 1;
}
}

private void KillApplication()
{
Process[] AllProcesses = Process.GetProcessesByName("ApplicationName");

// check to kill the right process
foreach (Process ApplicationProcess in AllProcesses)
{
if (myHashtable.ContainsKey(ApplicationProcess.Id) == false)
SPSecurity.RunWithElevatedPrivileges(delegate()
{
ApplicationProcess.Kill();
});
}

AllProcesses = null;
}


Happy Coding !!!

Monday, December 27, 2010

Access denied by Business Data Connectivity

When I tried to fetch SQL Data using BDC using diffrent user then Administrator below error I found. Open Central Administrator Site and then open Application Management Tab's Manage Service Appplications link as below.
Select Business Data Connectivity Service as below
Then after checked your external content type's set object permissions as below.
Add your Users and set permissions as below

Now Open your External List & see all SQL Data.
Happy Coding !!!

Tuesday, December 14, 2010

Chat with SharePoint MVP Experts

Now you can ask your tough sharepoint questions to SharePoint MVP via chat.
Its cover
  • WSS,
  • MOSS
  • SharePoint 2010
Topics include
  • setup and administration,
  • design,
  • development and general questions.

Timing

9:00 – 10:00 A.M. Pacific Time
12:00 - 1:00 P.M. Eastern Time
16:00 - 17:00 GMT

MSDN: msdn.microsoft.com/en-us/chats/default.aspx

Happy Coding !!!