Is there any way i can add return parameters to the handler data so that i can use it back in client??
Here is my code and unfortunately it doesnt work.
Once the file got uploaded from silverlight to the server folder specified then the process for uploading the file to sharepoint document libraray or picture libraray starts. Once the file got uploaded to the directory then the URL of the file should be returned to client so that the url will be saved in the Database.
I tried several ways and none working. I even used the AddReturnParam with value and key.
There is no exception or error. In the server it adds properly but in client i couldnt able to see any values.
Let me know what is wrong with the code. For me this looks like a bug as any control after extending & overriding you should be able to add values into base return type after the main process is completed.
Regards,
Nagendra
Here is my code and unfortunately it doesnt work.
string
_key =
"DocLibKey_"
;
//Used to map the sharepoint site document libraries.
private
static
string
_fileurl;
private
static
Exception _expThrown;
public
override
void
ProcessStream()
{
base
.ProcessStream();
try
{
if
(
this
.IsFinalFileRequest())
{
string
filename =
this
.Request.Form[
"RadUAG_fileName"
];
string
physicalfolderpath = HttpContext.Current.Server.MapPath(
this
.TargetFolder);
using
(FileStream fstream =
new
FileStream(physicalfolderpath +
"\\"
+ filename, FileMode.Open))
{
SPSecurity.RunWithElevatedPrivileges(
delegate
{
//SPSite objSite = new SPSite(SPContext.Current.Web.Url);
SPSite objSite =
new
SPSite(
"siteurl"
);
using
(SPWeb myWeb = objSite.OpenWeb())
{
myWeb.AllowUnsafeUpdates =
true
;
switch
(myWeb.Lists[_key +
this
.TargetFolder].GetType().ToString())
{
case
"Microsoft.SharePoint.SPPictureLibrary"
:
//this.AddReturnParam("Type", myWeb.Lists[_key + this.TargetFolder].GetType().ToString());
SPPictureLibrary objLocationMapLibrary = (SPPictureLibrary)myWeb.Lists[_key + TargetFolder];
SPFile spPictureFile = objLocationMapLibrary.RootFolder.Files.Add(filename, fstream,
true
);
if
(spPictureFile !=
null
)
{
//this.Result.Add("FileURL", spPictureFile.Url);
_fileurl = spPictureFile.Url;
}
break
;
default
:
//this.AddReturnParam("Type", myWeb.Lists[_key + this.TargetFolder].GetType().ToString());
SPFile spDocLibFile = myWeb.Lists[_key + TargetFolder].RootFolder.Files.Add(filename, fstream,
true
);
if
(spDocLibFile !=
null
)
{
//this.Result.Add("FileURL", spDocLibFile.Url);
_fileurl = spDocLibFile.Url;
}
break
;
}
myWeb.AllowUnsafeUpdates =
false
;
}
}
);
}
//base.GetAssociatedData().Add("FileURL", "xyz");
//this.AddReturnParam("FileURL", "xyz");
//_fileurl="xyz";
File.Delete(physicalfolderpath +
"\\"
+ filename);
}
}
catch
(Exception exp)
{
_expThrown = exp;
//this._result.Add("EXCEPTION", exp);
}
}
public
override
Dictionary<
string
,
object
> GetAssociatedData()
{
Dictionary<
string
,
object
> associatedData =
base
.GetAssociatedData();
if
(
this
.IsFinalFileRequest())
{
if
(_fileurl !=
null
)
{
if
(!associatedData.ContainsKey(
"FileURL"
))
associatedData.Add(
"FileURL"
, _fileurl);
}
if
(_expThrown !=
null
)
{
if
(!associatedData.ContainsKey(
"EXCEPTION"
))
associatedData.Add(
"EXCEPTION"
, _expThrown);
}
}
return
associatedData;
}
Once the file got uploaded from silverlight to the server folder specified then the process for uploading the file to sharepoint document libraray or picture libraray starts. Once the file got uploaded to the directory then the URL of the file should be returned to client so that the url will be saved in the Database.
I tried several ways and none working. I even used the AddReturnParam with value and key.
There is no exception or error. In the server it adds properly but in client i couldnt able to see any values.
Let me know what is wrong with the code. For me this looks like a bug as any control after extending & overriding you should be able to add values into base return type after the main process is completed.
Regards,
Nagendra