the best overloaded method match for ScriptManager.RegisterStartupScript has some invalid arguments c#
-
12-12-2020 - |
Question
namespace SXPSetDisposalDate.SetDisposalDate
{
public class SetDisposalDate : SPItemEventReceiver{
/// <summary>
/// An item is being checked in.
/// </summary>
public override void ItemCheckingIn(SPItemEventProperties properties)
{
//if not migrated
if (ctName != rejectedcT)
{
}
else
{
//reject save because Content Type is migrated
ScriptManager.RegisterStartupScript(Page, this.GetType(), "Exception", "alert('Stop')", true);
}
}
}
}
I have this code on an event receiver in SharePoint which triggers when an item is checked in. When the content type doesn't equal a certain name then an alert pops up telling them to not use the content type selected. I am getting an error that reads
the best overloaded method match for ScriptManager.RegisterStartupScript has some invalid arguments
what am I doing wrong?
Solution
Try it as below:
public override void ItemCheckingIn(SPItemEventProperties properties)
{
try
{
//if not migrated
if (ctName != rejectedcT)
{
}
else
{
//reject save because Content Type is migrated
properties.ErrorMessage = "Stop, add the correct content type";
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.Cancel = true;
}
}
catch(Exception ex)
{
properties.ErrorMessage = "Stop, add the correct content type";
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.Cancel = true;
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange