Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing on a c# web project with aspx pages and need to create a dll with several dialogboxes made of Panels and DIV's. It is possible for me to create a library and call it from the codebehind in my mainproject. But I can't put a DIV, Panel or Textbox in the dll and reference these controls inside the dll.

What I have tried:

I have tried to make a single webproject with a single page and put a webform inside this project with my dialogboxes and call the main routine from my aspx page in codebehind. but the Panel and DIV are null when these controls are referenced.

my aspx file contains the following code:
ASP.NET
<body>
    <form id="form1" runat="server">
        <div id="modalBackground" runat="server" class="modalBackground" visible="false"></div>
        <asp:Panel ID="panAddAccountNumber" runat="server" CssClass="modalPopup" Style="display:none" Width="362px">
            <div class="header">
                test
            </div>
            <div class="body">
            </div>
            <div class="footer" align="right">
                <asp:Button ID="btnAddAccountNumberYes" runat="server" Text="Ok" CssClass="yes" />
                <asp:Button ID="btnAddAccountNumberCancel" runat="server" Text="Annuller" CssClass="no" />
            </div>
        </asp:Panel>
        <div>
        </div>
    </form>
</body>

and my C# file contains the following code:
C#
public partial class InvoiceDialogbox : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public HtmlGenericControl cModalBackground
    {
        get
        {
            return modalBackground;
        }
    }

    public Panel cAddAccountNumber
    {
        get
        {
            return panAddAccountNumber;
        }
    }

    public static void ShowInvoice(Int64 vID)
    {
        InvoiceDialogbox vvv = new InvoiceDialogbox();
        vvv.cModalBackground.Visible = true;
        vvv.cAddAccountNumber.Style.Remove("display");
        vvv.cAddAccountNumber.Style.Add("display", "inline-block");
    }
}

But
cModalBackground
and
cAddAccountNumber
are both null when the dll is used from my codebehind in my main project.

So my question is: what can I do for accessing these controls which are null? And if I can't do it in this way - does there exists a another way for creating a dll for a dialogbox structure?

Thanks in advance.
Posted
Comments
[no name] 7-Oct-23 11:04am    
A "class library" still only holds "templates"; you have to "create" an "instance" of said class by "referencing" the class library in question and invoking the constructor of the class in question.
MichaelEriksen 7-Oct-23 11:21am    
Thanks for commenting - but do you have an example of what I need to do? I do not exactly know what you mean :-(

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900