troubleshooting Question

How do I invoke a C# List within a button click event?

Avatar of aspnet-scotland
aspnet-scotlandFlag for United Kingdom of Great Britain and Northern Ireland asked on
.NET ProgrammingC#Microsoft SharePoint
9 Comments1 Solution455 ViewsLast Modified:
Hi,

I have the attached code which contains a button click event that is trying to invoke the list  SendEmails but my "emailsObject" returns null? Is my code wrong? Basically I have written a proxy operation to allow me to send an email within a sharepoint 2010 sandbox solution. Within debug my "args" are being populated but my button click event doesn't seem to send the emails using Utility.SendEmail written within my proxy?


void btnSendMessage_Click(object sender, EventArgs e)
        {
            SendEmails();

            // Let the user know the message was sent
            lblMessageSent.Visible = true;
        }

public List<GetWebsiteBTEmailProxyOp.BTEmail> SendEmails()
        {
            String fourPartProxyAssemblyName = "Contoso.SharePoint.UserCode.BTEmailOp, " +
                                   "Version=1.0.0.0, " +
                                   "Culture=neutral, " +
                                   "PublicKeyToken=91a5084675c2ec42";

            String proxyOperationClassName = "Contoso.SharePoint.UserCode.GetWebsiteBTEmailProxyOp";
            WebsiteBTEmailProxyOperationArgs args = new WebsiteBTEmailProxyOperationArgs(txtContactName.Text, txtEmailAddress.Text, txtPhone.Text, txtMessage.Text);

            Object emailsObject = SPUtility.ExecuteRegisteredProxyOperation(fourPartProxyAssemblyName, proxyOperationClassName, args);

            List<GetWebsiteBTEmailProxyOp.BTEmail> btEmails = emailsObject as List<GetWebsiteBTEmailProxyOp.BTEmail>;

            return btEmails;
        }
ASKER CERTIFIED SOLUTION
fritzfrancis

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros