Tuesday, April 2, 2013
Easy but worth publishing.. Uploading document to Doc Library via Code..
public static void PushFileToDocLib()
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("site url"))
{
using (SPWeb web = site.OpenWeb())
{
string fileToUpload = "c:\\ExcelWorkBookName.xlsx";
if (!System.IO.File.Exists(fileToUpload))
throw new FileNotFoundException("File Not Found", fileToUpload);
SPFolder docLibrary = web.Folders["Document Lib Name"];
Boolean ExistingFiles = true;
string fileName = System.IO.Path.GetFileName(fileToUpload);
FileStream fileStream = File.OpenRead(fileToUpload);
SPFile spFile = docLibrary.Files.Add(fileName, fileStream, ExistingFiles);
docLibrary.Update();
}
}
});
}
Tuesday, January 15, 2013
Enable/Disable Asp validators via Javascript..
Yes.. it is among the most fundamental functions of javascript but I admit that i didnt know about it. So i tend to share to those who sometime somewhere stands on my feet.
Ok, there is a function call ValidatorEnable(control, bool status).
This function enables/disables the validator control specified as parameter in the fucntion.
For Eg:
function ActivateValidator(Ctrl) {
alert(Ctrl.value.length);
if (Ctrl.value.length > 0) {
var myValidator = document.getElementById('<%=rfvLowTier.ClientID %>');
ValidatorEnable(myValidator, true);
} Hope this helps!
Ok, there is a function call ValidatorEnable(control, bool status).
This function enables/disables the validator control specified as parameter in the fucntion.
For Eg:
function ActivateValidator(Ctrl) {
alert(Ctrl.value.length);
if (Ctrl.value.length > 0) {
var myValidator = document.getElementById('<%=rfvLowTier.ClientID %>');
ValidatorEnable(myValidator, true);
} Hope this helps!
Wednesday, September 12, 2012
Kerberos--
Guys.. I m preparing small documetation regarding the Kerberos in Sharepoint and the double hop issues.
Meantime, if you guys have any related issues with Sharepoint Kervberos, feel free to post questions.
We got one while trying to connect to OLAP via custom webpart where we were not able to connect to OLAP cube. Finally we nailed it down and saw another beauty of Kerberos.
Roshan
Meantime, if you guys have any related issues with Sharepoint Kervberos, feel free to post questions.
We got one while trying to connect to OLAP via custom webpart where we were not able to connect to OLAP cube. Finally we nailed it down and saw another beauty of Kerberos.
Roshan
Tuesday, March 6, 2012
LINQ to SQL not updating the record in the table
Hi,
I was using LINQ to SQL (first time to be honest) and i was excited. So one of my task was to update db table for which i used the following code.
MPSCGetDataFromDBDataContext dc = new MPSCGetDataFromDBDataContext();
MPSC_WFStatus wfStatus = dc.MPSC_WFStatus.Single(p => p.WFID == item.WFID);
wfStatus.IsNew = 1;
dc.SubmitChanges();
But it was not updating the data table. So after hitting my head on wall for a while, finally i broke it and found the silly mistake that i made:
---- Define Primary key on dbml.
aha... what a relief.. its updating the tables. Just posting incase any of you are in the same situation.
-Cheers!
Thursday, October 27, 2011
Accessing Sharepoint DateTimeControl in Javascript
Hi Guys,
I thought it worth posting this on how to access the sharepoint DatetimeControl in case if you are creating custom webparts with this controls or writing some custom javascripts.
in javascript:
function GetDate()
{
var sdate=document.getElementbyId('<%=dateControlName.Controls[0].ClientID %>');
alert (sdate.value);
}
Cheers!
Thursday, September 23, 2010
Getting List Internal Name
Hi Guys,
I ran into a very wierd but intresting issue today. The client changed the document library name and suddenly even handler started throwing error saying the file path does not matched. Whenever the list name changes, the internal name remains same and the path of the file remains with the internal name. So my properties.ListTitle was picking the display name and could not find the file.
So always better approach is to use list internal name.
Not simple but not even complex:
I used
properties.ListItem.ListItems.List.RootFolder.Name
and it gave me the list internal name and the issue was fixed. Cheers!
So, the basic logic is that, if you want to use list internal name, then you have to follow
objList.RootFolder.Name
I ran into a very wierd but intresting issue today. The client changed the document library name and suddenly even handler started throwing error saying the file path does not matched. Whenever the list name changes, the internal name remains same and the path of the file remains with the internal name. So my properties.ListTitle was picking the display name and could not find the file.
So always better approach is to use list internal name.
Not simple but not even complex:
I used
properties.ListItem.ListItems.List.RootFolder.Name
and it gave me the list internal name and the issue was fixed. Cheers!
So, the basic logic is that, if you want to use list internal name, then you have to follow
objList.RootFolder.Name
Tuesday, September 14, 2010
Twitter Friends Timeline and oAuth
Hi Guys,
If you guys had done any task regarding Twitter feed webpart, you should know by now that your webpart is not working anymore. The reason being the authentication of twitter has been changed from basic authentication ot oAuth.
currently i am working on my enhancement on twitter webpart to sync the authntication with oAuth. Let me know if you guys need a code snapshots.
Thanks
If you guys had done any task regarding Twitter feed webpart, you should know by now that your webpart is not working anymore. The reason being the authentication of twitter has been changed from basic authentication ot oAuth.
currently i am working on my enhancement on twitter webpart to sync the authntication with oAuth. Let me know if you guys need a code snapshots.
Thanks
Subscribe to:
Posts (Atom)