the best overloaded method match for ScriptManager.RegisterStartupScript has some invalid arguments c#

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/203411

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?

有帮助吗?

解决方案

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;
    }
}
许可以下: CC-BY-SA归因
scroll top