Nested forms and server-side control in ASP.NET

Discussion in 'Software' started by mredelin, Dec 20, 2007.

  1. mredelin

    mredelin

    Joined:
    Dec 20, 2007
    Messages:
    1
    Likes Received:
    0
    I am designing a web site with a masterpage and a number of child pages. Because Javascript is necessary both for the Masterpage and for the child pages, I have included a single <FORM> tag in the masterpage:

    <form id="form1" name="form1" runat="server">

    The child pages fit inside this form tag, and do not contain any form tags of their own (to avoid getting an error message stating that I can have only one server side control).

    The problem I am having is that Javascript won't recognize any HTML form object from the child pages -- e.g if I try to access a drop down menu with id=”Cause” in one of my child pages, the debugger gets to the following line of Javascript code:

    var QuestionList = document.form1.Cause;

    and returns the following error message:

    “Microsoft Jscript runtime error: ‘document.form1.cause’ is null or not an object”

    Any ideas? It won't work to create a second form on the child page and embed the "Cause" drop down menu in that, because then I will need to use a second 'runat="server"' statement -- one on the masterpage, one on the child page -- and will get a message saying the page won't load because there is more than one server side control.
     
    mredelin, Dec 20, 2007
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.