[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

Please help me debug my web part code.

Asked by Jovix in MS SharePoint

Can someone please help me check my code. I'm trying to create a web part that will check a Form Library and return the number of records or forms that the current user has added to the form library.

The web part is deployed to the bin, and it has been added as a safe control in the web.config file, but it errors out whenever I run my page. The error: An unexpected error has occurred.

Thanks...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
 
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
 
namespace HelloWorld
{
    [Guid("1747ae83-9f82-408c-9203-12e3debed7ab")]
    public class HelloWorld : System.Web.UI.WebControls.WebParts.WebPart
    {
        public HelloWorld()
        {
        }
 
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
 
            // TODO: add custom rendering code here.
            Label label = new Label();
            label.ID = "label";
            this.Controls.Add(label);
 
            string caml = "<Where><Eq><FieldRef Name='Author'/><Value Type='Integer'><UserID Type='Integer'/></Value></Eq></Where>";
 
            SPQuery query = new SPQuery();
            query.Query = caml;
 
            SPWeb currentWeb = SPContext.Current.Web;
            SPList list = currentWeb.Lists["Acknowledgement"];
 
            SPListItemCollection results = list.GetItems(query);
 
 
            label.Text = results.Count + " results found.";
 
        }
    }
}
[+][-]06/06/09 04:44 AM, ID: 24562724Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/08/09 07:21 AM, ID: 24572382Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625