How do build aspx code that allows you to re-use code.

Posted on 2012-08-22
Last Modified: 2012-08-22
  How do you build aspx code that re-uses aspx code that you have developed instead of adding the same code over and over again?

  I have some lines of aspx code that are used in the forms that I want to maintain in one place instead of sticking it on each new form..

Question by:KeeterBlack
    LVL 33

    Expert Comment

    They're called "classes".  You can have as many or as few as you want, and use them to organize your code any way you like.

    Author Comment


       No... Not Classes..  

      I am talking about adding plain old aspx code(markup) that I use over and over again.

      Unless there is someway to make a class with Aspx code.

    Example of code used in many different forms:
                      <asp:Panel id="Panel1" runat="server" horizontalalign="Center">
                            <div id="submitbutton" runat="server">
                                  <igtxt:WebImageButton id="btnSubmit" runat="server" text="Submit Changes" height="40px"
                                  <igtxt:WebImageButton id="btnDismiss" runat="server" autosubmit="False" height="40px"
                                        text="Dismiss Changes">
                                        <ClientSideEvents click="CancelClicked" />
                                  <igtxt:WebImageButton id="btnDelete" runat="server" height="40px" text="Delete Record">
                                        <ClientSideEvents click="delRecord" />

    The above code is needed in many different forms.

    LVL 5

    Accepted Solution

    Try putting this in  a usercontrol ascx. Then it's available in one place and any mods are reflected on all existing forms

    Can be dropped onto any page like any page control

    Author Closing Comment


    That will work!!!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now