Montag, 14. Februar 2011
the referenced file is not allowed on this page - Sharepoint 2010
It seems you are trying to register a user-control from the layouts folder. Put it into the controltemplates folder and it should work.
Donnerstag, 27. Januar 2011
Error Sharepoint 2010 "Could not load type" when loading a custom Page
Ich habe eine bestehende Sharepoint Seite durch eine eigene ersetzt und wollte dann in der Page Deklaration auf meine Klasse verweisen. Nach dem Deployment bekam ich oben genannten Fehler. Dieser tritt nicht auf, wenn man in der Page Deklaration im Inherit Attribut nicht nur auf die Klasse verweist, sondern auf die Assembly, den Token und Version.
Alt:
<%@ Page Language="C#" Inherits="[mein Namespace].[meine Klasse]" MasterPageFile="~/_layouts/dialog.master" %>
Neu:
<%@ Page Language="C#" Inherits="[mein Namespace].[meine Klasse], [Assemblyname], Version=1.0.0.0, Culture=neutral, PublicKeyToken=[Token ID]" MasterPageFile="~/_layouts/dialog.master" %>
I had replaced an existing Sharepoint page with a custom one and referenced in the page declaration to my class. After deployment I got the error mentioned above. This error won't raise, when you extend the inherit attribute with the assembly, token and version.
Old:
<%@ Page Language="C#" Inherits="[my namespace].[my class]" MasterPageFile="~/_layouts/dialog.master" %>
New:
<%@ Page Language="C#" Inherits="[my namespace].[my class], [assembly-name], Version=1.0.0.0, Culture=neutral, PublicKeyToken=[Token ID]" MasterPageFile="~/_layouts/dialog.master" %>
Alt:
<%@ Page Language="C#" Inherits="[mein Namespace].[meine Klasse]" MasterPageFile="~/_layouts/dialog.master" %>
Neu:
<%@ Page Language="C#" Inherits="[mein Namespace].[meine Klasse], [Assemblyname], Version=1.0.0.0, Culture=neutral, PublicKeyToken=[Token ID]" MasterPageFile="~/_layouts/dialog.master" %>
I had replaced an existing Sharepoint page with a custom one and referenced in the page declaration to my class. After deployment I got the error mentioned above. This error won't raise, when you extend the inherit attribute with the assembly, token and version.
Old:
<%@ Page Language="C#" Inherits="[my namespace].[my class]" MasterPageFile="~/_layouts/dialog.master" %>
New:
<%@ Page Language="C#" Inherits="[my namespace].[my class], [assembly-name], Version=1.0.0.0, Culture=neutral, PublicKeyToken=[Token ID]" MasterPageFile="~/_layouts/dialog.master" %>
Mittwoch, 26. Januar 2011
Error occured in deployment step cannot connect [Url]
Ein Fehler, warum er nicht auf eine bestimmte Url deployen kann aus dem Visual Studio 2010, kann sein, dass man entweder im Host-file und/oder dem (Zentraladministration) System Settings -> Configure alternate access mappings falsche Urls als Verweis eingetragen hat.
Wenn man lokal entwickelt, müssen die Url im Visual Studio der Url im Access-mapping und der Url im Host-file entsprechen.
The error, why you can't deploy out of Visual Studio 2010 to a specified url, can be caused, because you might not have the correct urls set in the host-file and/or (Central administration) System Settings -> Configure alternate access mappings.
When developing locally, the urls need to be the same in Visual Studio, access-mapping and the host-file.
Wenn man lokal entwickelt, müssen die Url im Visual Studio der Url im Access-mapping und der Url im Host-file entsprechen.
The error, why you can't deploy out of Visual Studio 2010 to a specified url, can be caused, because you might not have the correct urls set in the host-file and/or (Central administration) System Settings -> Configure alternate access mappings.
When developing locally, the urls need to be the same in Visual Studio, access-mapping and the host-file.
Freitag, 26. November 2010
The VM session was closed before any attempt to power it on
Meine VM VirtualBox hatte oben genannten Error beim Starten. Hierzu habe ich folgendes geändert:
Ich habe "Ändern" geklickt. Dem Button neben "Neu". Dort habe ich die Bootreihenfolge geändert. Also HD zuerst. Danach lief die Maschine wieder.
My VM VirtualBox had the above mentioned error, when trying to start. Therefore I made the following changes:
I clicked "change" right next to "new" and then changed the sort order of the boot-steps and have set the HD first. Then it worked and started correctly.
Ich habe "Ändern" geklickt. Dem Button neben "Neu". Dort habe ich die Bootreihenfolge geändert. Also HD zuerst. Danach lief die Maschine wieder.
My VM VirtualBox had the above mentioned error, when trying to start. Therefore I made the following changes:
I clicked "change" right next to "new" and then changed the sort order of the boot-steps and have set the HD first. Then it worked and started correctly.
Donnerstag, 21. Oktober 2010
Custom Field Type -> User : <Field Name="ParentType">User</Field>
Wenn man ein Custom Field Type des ParentTypes User erstellen will, dann geht man vor wie bisher, nur an zwei Stellen müsste man etwas ändern.
1. fldtypes_[your name].xml
Dort muss man den folgenden ParentType definieren:
<Field Name="ParentType">User</Field>
2. FieldControl verlangt beim get der überschriebenen Methode Value ein gewisses Format [Sharepoint UserId];#[Sharepoint UserName] als String.
public override object Value
{
get
{
return "1;#Mein Name";
}
}
Sharepoint UserId bzw. UserName erhält man wie folgt:
Aktueller User:
SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.RootWeb)
{
SPUser oUser = oWebsite.CurrentUser;
oUser.Name; //Der Sharepoint UserName
oUser.ID; //Die Sharepoint UserId
}
Ein User aus einer Gruppe:
using (SPSite spSite = new SPSite("[URL zu meiner Sharepointinstanz]"))
{
using (SPWeb spWeb = spSite.RootWeb)
{
foreach (SPUser user in spWeb.SiteGroups["[Mein Gruppenname]"].Users)
{
user.Name;
user.ID;
}
}
}
3. Ihre Field Klasse erbt bei normalen Custom Field Types von der Basisklasse SPField. In diesem Fall muss es SPFieldUser sein. Der restliche Code bleibt gleich. Wenn man einen Defaultwert setzen will, kann man die dazugehörige Eigenschaft überschreiben.
public class [Ihr Name]Field : SPFieldUser
{ ...
HINWEIS: Wenn Sie SPField als Basisklasse benutzen, dann bleibt der Wert in der Liste leer.
If you want to create a custom-field-type of parent-type User, then you just create your custom-field-type like any other and make changes at two spots.
1. fldtypes_[your name].xml
There you have to define the following ParentType:
<Field Name="ParentType">User</Field>
2. FieldControl requires a special format in the get function of the overridden method Value. [Sharepoint UserId];#[Sharepoint UserName] as string.
public override object Value
{
get
{
return "1;#My name";
}
}
You can get the values of Sharepoint UserId or UserName like this:
Current user:
SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.RootWeb)
{
SPUser oUser = oWebsite.CurrentUser;
oUser.Name; //The Sharepoint UserName
oUser.ID; //The Sharepoint UserId
}
User from a specified group:
using (SPSite spSite = new SPSite("[URL of my Sharepoint-instance]"))
{
using (SPWeb spWeb = spSite.RootWeb)
{
foreach (SPUser user in spWeb.SiteGroups["[My group-name]"].Users)
{
user.Name; //The Sharepoint UserName
user.ID; //The Sharepoint UserId
}
}
}
3. Usual custom-field-types inherit from the base-class SPField. In this case your class needs to inherit from SPFieldUser. The rest of the code remains the same. If you want to set a default-value, then you need to override the property DefaultValue.
public class [Your name]Field : SPFieldUser
{ ...
HINT: If you do use SPField as the base class, then the value in the list will remain empty.
1. fldtypes_[your name].xml
Dort muss man den folgenden ParentType definieren:
<Field Name="ParentType">User</Field>
2. FieldControl verlangt beim get der überschriebenen Methode Value ein gewisses Format [Sharepoint UserId];#[Sharepoint UserName] als String.
public override object Value
{
get
{
return "1;#Mein Name";
}
}
Sharepoint UserId bzw. UserName erhält man wie folgt:
Aktueller User:
SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.RootWeb)
{
SPUser oUser = oWebsite.CurrentUser;
oUser.Name; //Der Sharepoint UserName
oUser.ID; //Die Sharepoint UserId
}
Ein User aus einer Gruppe:
using (SPSite spSite = new SPSite("[URL zu meiner Sharepointinstanz]"))
{
using (SPWeb spWeb = spSite.RootWeb)
{
foreach (SPUser user in spWeb.SiteGroups["[Mein Gruppenname]"].Users)
{
user.Name;
user.ID;
}
}
}
3. Ihre Field Klasse erbt bei normalen Custom Field Types von der Basisklasse SPField. In diesem Fall muss es SPFieldUser sein. Der restliche Code bleibt gleich. Wenn man einen Defaultwert setzen will, kann man die dazugehörige Eigenschaft überschreiben.
public class [Ihr Name]Field : SPFieldUser
{ ...
HINWEIS: Wenn Sie SPField als Basisklasse benutzen, dann bleibt der Wert in der Liste leer.
If you want to create a custom-field-type of parent-type User, then you just create your custom-field-type like any other and make changes at two spots.
1. fldtypes_[your name].xml
There you have to define the following ParentType:
<Field Name="ParentType">User</Field>
2. FieldControl requires a special format in the get function of the overridden method Value. [Sharepoint UserId];#[Sharepoint UserName] as string.
public override object Value
{
get
{
return "1;#My name";
}
}
You can get the values of Sharepoint UserId or UserName like this:
Current user:
SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.RootWeb)
{
SPUser oUser = oWebsite.CurrentUser;
oUser.Name; //The Sharepoint UserName
oUser.ID; //The Sharepoint UserId
}
User from a specified group:
using (SPSite spSite = new SPSite("[URL of my Sharepoint-instance]"))
{
using (SPWeb spWeb = spSite.RootWeb)
{
foreach (SPUser user in spWeb.SiteGroups["[My group-name]"].Users)
{
user.Name; //The Sharepoint UserName
user.ID; //The Sharepoint UserId
}
}
}
3. Usual custom-field-types inherit from the base-class SPField. In this case your class needs to inherit from SPFieldUser. The rest of the code remains the same. If you want to set a default-value, then you need to override the property DefaultValue.
public class [Your name]Field : SPFieldUser
{ ...
HINT: If you do use SPField as the base class, then the value in the list will remain empty.
Mehrere SP.UI.ModalDialog.showModalDialog - CallBack
Wenn man mehrere SP.UI.ModalDialog.showModalDialog Fenster auf einer Seite platziert, ist es wichtig, dass die Callback Methoden unterschiedlich heissen. Ansonsten funktioniert immer nur ein Dialog Callback. Deshalb in den Properties des Dialogs immer einen anderen Methodennamen verwenden.
If you are using multiple SP.UI.ModalDialog.showModalDialog windows on your page, be aware to have different callback methods defined. Otherwise there will be just one callback working. Therefore set in the properties of your dialog always a different method.
Dialog 1:
function OpenDialog1()
{
var options1 = {
url: '/_layouts/MyDialog.aspx',
title: 'MyDialog',
allowMaximize: false,
showClose: true,
width: 400,
height: 400,
dialogReturnValueCallback: DialogCallback1 };
SP.UI.ModalDialog.showModalDialog(options1);
}
function DialogCallback1(dialogResult, returnValue) {
[Your code on callback]
}
Dialog 2:
function OpenDialog2()
{
var options2 = {
url: '/_layouts/MySecondDialog.aspx',
title: 'MySecondDialog',
allowMaximize: false,
showClose: true,
width: 400,
height: 400,
dialogReturnValueCallback: DialogCallback2 };
SP.UI.ModalDialog.showModalDialog(options2);
}
function DialogCallback2(dialogResult, returnValue) {
[Your code on callback]
}
Es existiert noch eine andere Schreibweise ->
There is also another way of defining the dialog ->
Dialog 1:
function OpenDialog1()
{
SP.UI.ModalDialog.showModalDialog(options);
var options1 = SP.UI.$create_DialogOptions();
options1.url = '/_layouts/MyDialog.aspx';
options1.width = 400;
options1.height = 400;
options1.allowMaximize = false;
options1.showClose = true;
options1.dialogReturnValueCallback = DialogCallback1;
SP.UI.ModalDialog.showModalDialog(options1);");
}
function DialogCallback1(dialogResult, returnValue) {
[Your code on callback]
}
Dialog 2:
function OpenDialog2()
{
SP.UI.ModalDialog.showModalDialog(options);
var options2 = SP.UI.$create_DialogOptions();
options2.url = '/_layouts/MySecondDialog.aspx';
options2.width = 400;
options2.height = 400;
options2.allowMaximize = false;
options2.showClose = true;
options2.dialogReturnValueCallback = DialogCallback2;
SP.UI.ModalDialog.showModalDialog(options2);
}
function DialogCallback2(dialogResult, returnValue) {
[Your code on callback]
}
If you are using multiple SP.UI.ModalDialog.showModalDialog windows on your page, be aware to have different callback methods defined. Otherwise there will be just one callback working. Therefore set in the properties of your dialog always a different method.
Dialog 1:
function OpenDialog1()
{
var options1 = {
url: '/_layouts/MyDialog.aspx',
title: 'MyDialog',
allowMaximize: false,
showClose: true,
width: 400,
height: 400,
dialogReturnValueCallback: DialogCallback1 };
SP.UI.ModalDialog.showModalDialog(options1);
}
function DialogCallback1(dialogResult, returnValue) {
[Your code on callback]
}
Dialog 2:
function OpenDialog2()
{
var options2 = {
url: '/_layouts/MySecondDialog.aspx',
title: 'MySecondDialog',
allowMaximize: false,
showClose: true,
width: 400,
height: 400,
dialogReturnValueCallback: DialogCallback2 };
SP.UI.ModalDialog.showModalDialog(options2);
}
function DialogCallback2(dialogResult, returnValue) {
[Your code on callback]
}
Es existiert noch eine andere Schreibweise ->
There is also another way of defining the dialog ->
Dialog 1:
function OpenDialog1()
{
SP.UI.ModalDialog.showModalDialog(options);
var options1 = SP.UI.$create_DialogOptions();
options1.url = '/_layouts/MyDialog.aspx';
options1.width = 400;
options1.height = 400;
options1.allowMaximize = false;
options1.showClose = true;
options1.dialogReturnValueCallback = DialogCallback1;
SP.UI.ModalDialog.showModalDialog(options1);");
}
function DialogCallback1(dialogResult, returnValue) {
[Your code on callback]
}
Dialog 2:
function OpenDialog2()
{
SP.UI.ModalDialog.showModalDialog(options);
var options2 = SP.UI.$create_DialogOptions();
options2.url = '/_layouts/MySecondDialog.aspx';
options2.width = 400;
options2.height = 400;
options2.allowMaximize = false;
options2.showClose = true;
options2.dialogReturnValueCallback = DialogCallback2;
SP.UI.ModalDialog.showModalDialog(options2);
}
function DialogCallback2(dialogResult, returnValue) {
[Your code on callback]
}
Mittwoch, 20. Oktober 2010
Timerjob does not fire
Wenn Sie einen Timerjob erstellt und deployed haben, jedoch dieser keine Funktion auszuführen scheint, dann liegt es evtl. daran, dass die Assembly nicht neu instanziert wurde. Hierzu unter Verwaltung -> Services -> Sharepoint Timer neu starten. Danach den Timerjob nochmals starten.
When you created and deployed a timer-job, this seems not to work or functionallity seems not to fire, then the reason might be that the assembly was not initialized properly. Therefore restart Administrative Tools -> Services -> Sharepoint Timer. Then run your timer-job again.
When you created and deployed a timer-job, this seems not to work or functionallity seems not to fire, then the reason might be that the assembly was not initialized properly. Therefore restart Administrative Tools -> Services -> Sharepoint Timer. Then run your timer-job again.
Freitag, 15. Oktober 2010
Import spreadsheet als Liste
Bei dem Import eines Spreadsheets als Liste in Sharepoint 2010 hatte ich folgende Fehlermledungen:
1. "Automation server can't creat object"
ActiveX Controls sind nicht aktiviert oder Sie verwenden nicht den IE.
2. "The specified file is not a valid spreadsheet or contains no data to import"
Gehen Sie im Internet Explorer unter Tools -> Internet Options -> Security -> Trusted Sites -> Sites (Button) und fügen Sie die Seite hinzu. Sollte es dort eine Fehlermeldung geben, dann die Checkbox uncheck, denn Sie wollen wahrscheinlich eine http:// Seite hinzufügen.
When importing a spreadsheet as a list in Sharepoint 2010 I had the following error-messages:
1. "Automation server can't creat object"
ActiveX controls are either not activated or you are not using the IE.
2. "The specified file is not a valid spreadsheet or contains no data to import"
Go to Internet Explorer under Tools -> Internet Options -> Security -> Trusted Sites -> Sites (Button) and add this site to your trusted sites. If there is also an error-message, then uncheck the checkbox below, because you are trying to add a http:// site.
1. "Automation server can't creat object"
ActiveX Controls sind nicht aktiviert oder Sie verwenden nicht den IE.
2. "The specified file is not a valid spreadsheet or contains no data to import"
Gehen Sie im Internet Explorer unter Tools -> Internet Options -> Security -> Trusted Sites -> Sites (Button) und fügen Sie die Seite hinzu. Sollte es dort eine Fehlermeldung geben, dann die Checkbox uncheck, denn Sie wollen wahrscheinlich eine http:// Seite hinzufügen.
When importing a spreadsheet as a list in Sharepoint 2010 I had the following error-messages:
1. "Automation server can't creat object"
ActiveX controls are either not activated or you are not using the IE.
2. "The specified file is not a valid spreadsheet or contains no data to import"
Go to Internet Explorer under Tools -> Internet Options -> Security -> Trusted Sites -> Sites (Button) and add this site to your trusted sites. If there is also an error-message, then uncheck the checkbox below, because you are trying to add a http:// site.
Montag, 11. Oktober 2010
Sharepoint 2010 -> Javascript API window dialog
Wer in seiner Sharepointseite ein windows bzw. dialog selbst erstellen und öffnen will, der muss lediglich auf ein wenig Sharepoint API zurückgreifen:
If someone wants to use the window/dialog of Sharepoint in his Sharepoint instance, you can use the Sharepoint API like this:
<script type="text/javascript">
function MyDialog() {
var thisdialog = SP.UI.$create_DialogOptions();
thisdialog.url = "/_layouts/DialogDemo/MyDialog.htm";
thisdialog.width = 400;
thisdialog.height = 300;
SP.UI.ModalDialog.showModalDialog(thisdialog);
}
</script>
More information can be found here (thanks to the authors):
External blog
External blog
If someone wants to use the window/dialog of Sharepoint in his Sharepoint instance, you can use the Sharepoint API like this:
<script type="text/javascript">
function MyDialog() {
var thisdialog = SP.UI.$create_DialogOptions();
thisdialog.url = "/_layouts/DialogDemo/MyDialog.htm";
thisdialog.width = 400;
thisdialog.height = 300;
SP.UI.ModalDialog.showModalDialog(thisdialog);
}
</script>
More information can be found here (thanks to the authors):
External blog
External blog
Mittwoch, 6. Oktober 2010
Incompatible Web Part markup detected. Use *.dwp Web Part XML instead of *.webpart Web Part XML.
Wenn Sie ein eigenes Webpart erstellt haben und oben genannte Fehlermeldung erhalten, dann liegt es daran, dass das Webpart von der falschen Klasse erbt. Sie muss von folgender Klasse erben:
System.Web.UI.WebControls.WebParts.WebPart
und NICHT:
Microsoft.SharePoint.WebPartPages.WebPart
If you get the above mentioned error message, then you inherit from the wrong class in your custom webpart. It is supposed to inherit from:
System.Web.UI.WebControls.WebParts.WebPart
and NOT:
Microsoft.SharePoint.WebPartPages.WebPar
Hier ein kleines Beispiel, wie man ein eigenes Webpart erstellt:
Here is a little example how to create your custom webpart:
Link 1
System.Web.UI.WebControls.WebParts.WebPart
und NICHT:
Microsoft.SharePoint.WebPartPages.WebPart
If you get the above mentioned error message, then you inherit from the wrong class in your custom webpart. It is supposed to inherit from:
System.Web.UI.WebControls.WebParts.WebPart
and NOT:
Microsoft.SharePoint.WebPartPages.WebPar
Hier ein kleines Beispiel, wie man ein eigenes Webpart erstellt:
Here is a little example how to create your custom webpart:
Link 1
Abonnieren
Posts (Atom)