locked
When i insert code in page load getting unexpected Error after deploying visual web part? RRS feed

  • Question

  • Ascx page:

    <style type="text/css"> 

            .accordion { 

                width: 400px; 

            } 

             

            .accordionHeader { 

                border: 1px solid #2F4F4F; 

                color: white; 

                background-color: #2E4d7B; 

                font-family: Arial, Sans-Serif; 

                font-size: 12px; 

                font-weight: bold; 

                padding: 5px; 

                margin-top: 5px; 

                cursor: pointer; 

            } 

             

            .accordionHeaderSelected { 

                border: 1px solid #2F4F4F; 

                color: white; 

                background-color: #5078B3; 

                font-family: Arial, Sans-Serif; 

                font-size: 12px; 

                font-weight: bold; 

                padding: 5px; 

                margin-top: 5px; 

                cursor: pointer; 

            } 

             

            .accordionContent { 

                background-color: #D3DEEF; 

                border: 1px dashed #2F4F4F; 

                border-top: none; 

                padding: 5px; 

                padding-top: 10px; 

            } 

        </style> 

       

        <asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>

      

        <asp:Accordion ID="Accordion1" runat="server" CssClass="accordion"

                HeaderCssClass="accordionHeader"

                HeaderSelectedCssClass="accordionHeaderSelected"

                ContentCssClass="accordionContent" >

        <Panes>

        <asp:AccordionPane runat="server" ID="Pane1" >

        <Header>Simple Search</Header> 

            <Content>

    <asp:Label ID="Label1" runat="server" Text=" "></asp:Label>

       <asp:Button ID="SimpleSearch" runat="server" Text="Search" OnClick="SimpleSearch_Click" />

     

    </content>

          </asp:AccordionPane>

        <asp:AccordionPane runat="server" ID="AccordionPane1" >

        <Header>Advanced Search</Header> 

            <Content>

           <asp:Label ID="Label2" runat="server" Text=" "></asp:Label>

      <asp:Button ID="AdvanceSearch" runat="server" Text="Search" OnClick="AdvanceSearch_Click" />

    </content>  </asp:AccordionPane></asp:Accordion></Updatepanel>

     ASCX.CS

    protected void Page_Load(object sender, EventArgs e)

        {

    Label1.Visible=False;

    Label2.Visible=False;

     

    }

    protected void SimpleSearch_Click(object sender, EventArgs e)

        {

           Label1.text=System.Datetime.Now.Tostring();

    Label1.Visible=True;

     

        }      

       protected void Advance Search_Click(object sender, EventArgs e)

        {

            Label2.text=System.Datetime.Now.Tostring();

    Label2.Visible=True;

        }  

    if i remove code from page _load(.ascx.cs page)then working fine(Here i have  binding dropdownlist).


    Thursday, June 2, 2011 12:31 PM

All replies

  • Have you debugged the code yet? Check if Label1 and Label2 are null. Also is this a Farm or a Sandboxed solution
    Simon Rennocks | LinkedIn
    Thursday, June 2, 2011 1:02 PM
  • in page load Code:

     if (!IsPostBack)
            {


                Ess.Credentials = credentials;
                DataSet ds1 = new DataSet();
                ds1 = Ess.All();
                DropDownList1.DataSource = ds1.Tables[0];
                DropDownList1.DataValueField = "Location";
                DropDownList1.DataTextField = "Location";
                DropDownList1.DataBind();
    }

    in server the site is restricted so its not opened.so i unable to debug the web part.here i am using accordion control.if i remove the accordion control then its working fine

    Thursday, June 2, 2011 1:13 PM
  • I guess this is a farm solution since the ascx is provided.

    Anyway,

    1°I don't see DropDownlist1 in your ascx.

    2°you should check that there a ds1.Table[0] before using it it in the Datasource...

    3°your error might be in the Ess.All() ... what's in there ?

     

    I find strange that you cannot debug; don't you have a dev environnement ?

    Also before I forget, check the SharePoint Log (ULS)

     


    Serge Luca; MVP blog: http://sergeluca.spaces.live.com Devoteam Belgium. http://twitter.com/sergeluca
    Thursday, June 2, 2011 1:25 PM