Click here to Skip to main content
12,243,058 members (24,923 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
I have my own user defined control 'UC_Attachments:attachments ' (in panel pnlAttachment) which I want to raise as a popup (AJAX ModalPopupExtender 'extender_Attachment') from a page 'CompanyDetails.aspx' which is a content page of a master page named as 'MasterPage.master'.

<asp:Panel ID="pnlAttachment" runat="server" Visible="false">
     <UC_Attachments:attachments  runat="server" ID="MPE_Attachments"/>
</asp:Panel>
 
<cc1:modalpopupextender ID="extender_Attachment"  runat="server" TargetControlID="asplbl_ViewAttachment" PopupControlID="pnlAttachment" BackgroundCssClass="modalBackground" Drag="True" PopupDragHandleControlID="pnlAttachment">
</cc1:modalpopupextender>
 
<asp:Button ID="asplbl_ViewAttachment" runat="server" Text="View Attachment" CssClass="class_label" BorderStyle="None" BackColor="Transparent" Height="17px" style=" margin:2px; text-align:right; cursor:pointer;" onclick="asplbl_ViewAttachment_Click"/>

The code behind for button click is following

protected void asplbl_ViewAttachment_Click(object sender, EventArgs e)
{
     try
     {
          pnlAttachment.Visible = true;
 
          extender_Attachment.PopupControlID = pnlAttachment.ID;
          extender_Attachment.Show();
     }
     catch (Exception objExc)
     {
            
          throw objExc;
     }      
}


For user define control 'extender_Attachment' the code is following
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucattachment.ascx.cs" Inherits="Attachment" %>
 
<link href="App_Themes/blue/CSS/CommonCss.css" type="text/css" rel="Stylesheet" />
 
<%@ Register src="~/ucattachfiledisplay.ascx" TagName="attachfiledisplay" TagPrefix="UC_AttachFileDisplay" %>
 
<center>
<asp:Panel ID="pnlAttachmentUC" runat="server" CssClass="modalPopup">
     <!-- Some other code will appear here-->
     <asp:ImageButton ID="aspimgbtn_Add" runat="server" AlternateText="Add"xToolTip="Add Attachment" Width="24px" onclick="aspimgbtn_Add_Click"/>
     
</asp:Panel>
<asp:Panel ID="pnlUploadAttachment" runat="server" CssClass="modalPopup" Width="500px" Visible="false" >
 
     <UC_AttachFileDisplay:attachfiledisplay  runat="server" ID="MPE_AttachFileDispaly" />
 
</asp:Panel>
 
</center>

Same way I raise popup first time, I want to raise a another popup 'MPE_AttachFileDispaly' from panel'pnlUploadAttachment' which is again a user defined control which I want to raise using same AJAX ModalPopupExtender 'extender_Attachment'

The code behind for button aspimgbtn_Add click is following:

protected void aspimgbtn_Add_Click(object sender, ImageClickEventArgs e)
{
 
   pnlAttachmentUC.Visible = false;
   pnlUploadAttachment.Visible = true;
 
   ((ModalPopupExtender)(Page.FindControl("extender_Attachment"))).Show();
}

What I want to find is the control 'extender_Attachment' from the page 'CompanyDetails.aspx' and again show it.

When I run the program and then poiter comes on the line
((ModalPopupExtender)(Page.FindControl("extender_Attachment"))).Show();

it shows me an exception:

System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=App_Web_4cguope5
StackTrace:
at Attachment.aspimgbtn_Add_Click(Object sender, ImageClickEventArgs e) in d:\Progstar Systems Pvt Ltd\Projects\DJ Susanne\susanneweb\ucattachment.ascx.cs:line 28
at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:


Which means it is not able to find the control name I have specified. i.e. 'extender_Attachment'.

Could you please help me out to find the solution for this?

Coders, your help is appreciated.

Thank you in advance.

gnachiket
Posted 7-Apr-12 19:52pm
Comments
Mohamed Mitwalli 9-Apr-12 7:02am
   
Hi ,
What i understand is that you want to make extender_Attachment show more than one If it's right you can do it by code create extender assign properties using code instead of create in aspx

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Did you specify any ModalPopupExtender on extender_Attachment Control?
here you are trying to get control that is its own means extender_Attachment Control trying to open itself usinf button_Click so thats wh it gives error.

if you want to open inner Control of extender_AttachmentControl then add Modal PopupExtender in extender_Attachment Control
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 15 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100