More in this section

Forums / Developing with Sitefinity / Multiple forms on pages

Multiple forms on pages

4 posts, 0 answered
  1. Randy
    Randy avatar
    2 posts
    Registered:
    15 May 2008
    12 Sep 2008
    Link to this post
    We have been making great strides in customizing sitefinity considering we aren't .NET users normally, but we are unsure on how to proceed with multiple forms.  There are a couple instances that we are trying to figure out.  First, we have a simple text field form in the master page that we want to submit to a locations page so that we can search for a location near that zip code.  Secondly, we have a couple pages that will have contact forms on them.

    What is the best approach to go about these scenarios?  Thanks in advance for your responses!
  2. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    12 Sep 2008
    Link to this post
    Hi Randy,

    the thing about ASP.NET is that it can have only one form tag per page. While this seems awkward to anyone outside ASP.NET (it seemed awkward even to us when we migrated from .NET 1.1 to .NET 2.0, when this was introduced) it makes sense once you get the feel of it.

    Namely, in ASP.NET you do not actually submit a form, rather you create an event handler for each button (or any other UI element for that matter) and in the code behind you write an event handler. So for example you can have 3 buttons in one form - each button has its event handler - meaning that when the button is clicked the code inside of the event handler will be executed. So, even though you have only one form, by taking advantage of the event handlers it's like having three submit buttons.

    You can find plenty of great videos on ASP.NET here:
    http://www.asp.net/learn/videos/

    The first few talk about creating the user interface (form) and handling events and postbacks, which is exactly what you are looking for.

    I hope you will find this information helpful. Please let us know if there is anything else we can do for you.

    Regards,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Randy
    Randy avatar
    2 posts
    Registered:
    15 May 2008
    12 Sep 2008
    Link to this post
    That certainly makes sense.  So in the case of our master template, we have a textbox and a submit to allow the user to enter a zip code and it will take them to a store location page, showing the closest locations.  

    My assumption would be that we need to remove the html for that from the master page and replice it with a custom control so we can use the code page to send the variable on to another page.  Does that sound about right?  Thanks again.
  4. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    14 Sep 2008
    Link to this post
    Hello Randy,

    yes, this is exactly what you should do. We strongly suggest all the UI elements as well as logic for handling it is done through controls (be it User Control or Custom Control). The code in MasterPages should be placed only when the logic for it will be used on all the pages that use that template.

    By implementing the forms through user controls you will be able to reuse them on many different pages that can use different templates.

    Let us know if there is anything else we can do for you.

    Kind regards,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
4 posts, 0 answered