Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
ASP.NET
Below is my complete master page contains , on which i have multiple forms before , after main content place holder .. 

I know there should be only one form tage with runat=server which i kept inside my main content place holder so all my child pages who will take master pageget forms functionality ..

But when i created my next page which has this master page .. and i have created there repeatwer and inside it a button .. when i click this button it gave me following error 


"Control 'ContentPlaceHolder1_rptProducts_btnShowDetails_0' of type 'Button' must be placed inside a form tag with runat=server."


so i am wondering what went wrng ,,

<%@ Master Language="C#"  AutoEventWireup="true" CodeBehind="UserMaster.master.cs" Inherits="AutoSpareParts.UserMaster" %>



<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title></title>
    
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Spare Parts-Index</title>
        
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        
        
        
        <script type="text/javascript" src="../scripts/jquery.min.js"></script>
        
        
        
        
        <script type="text/javascript" src="../scripts/responsiveslides.min.js"></script>
        <script type="text/javascript" src="../scripts/jquery.tinycarousel.js"></script>

        <script type="text/javascript">
            // You can also use "$(window).load(function() {"
            $(function () {

                // Slideshow 1
                $("#slider1").responsiveSlides({
                    auto: true,
                    pager: true,
                    nav: true,
                    speed: 500,
                    maxwidth: 900,
                    namespace: "centered-btns"
                });

            });

        </script>

        <script type="text/javascript">
            $(document).ready(function () {
                $(".Title_FastFinder").click(function () {
                    $(".sercah_finder").slideToggle("slow");
                });

                $(".close").click(function () {
                    $(".sercah_finder").css("display", "none");
                });

            });
        </script>

        <script type="text/javascript">
            $(document).ready(function () {
                $('#slider2').tinycarousel();

            });
        </script>

        

        <script type="text/javascript" src="../scripts/jquery.contactable.js"></script>

        <script type="text/javascript">
            jQuery(function () {
                jQuery('#my-contact-div').contactable(
                {
                    subject: 'feedback URL:' + location.href,
                    url: '',
                    name: 'Name',
                    email: 'Email',
                    dropdownTitle: 'Services',
                    dropdownOptions: ['Repairing', 'Rent', 'Buy'],
                    message: 'Message',
                    submit: 'SEND',
                    recievedMsg: 'Thank you for your message',
                    notRecievedMsg: 'Sorry but your message could not be sent, try again later',
                    disclaimer: 'Please feel free to get in touch, we value your feedback',
                    hideOnSubmit: true
                });
            });
        </script>

        <script src="scripts/jquery-ui.js"></script>

        <script type="text/javascript">
            $(document).ready(function () {
                var isMobile = window.matchMedia("only screen and (max-width: 1024px)");

                if (isMobile.matches) {
                    jQuery("#nav1 li a").on("click", function (e) {
                        if (jQuery(this).parent().has("ul")) {
                            e.preventDefault();
                        }
                        $(this).next('ul').slideToggle();
                    });
                }
                $(".nav").click(function () {
                    $("ul#nav1").toggle();

                });

            });
        </script>

    
</head>
<body>
    
    
    
        
        
            
            
            
                
                    
                         
                             
                                 
                                    
                
                
                    Register Log In Currencies
                    <select class="currency_boxtop">
                        <option>Rupees</option>
                        <option>Euro</option>
                        <option>Us Dollar</option>
                    </select>
                
                
            
            
        
        
    
    

    
    
        
        
            
                
                    
            
            
                <form name="search" method="post" action="">
                    <input type="text" name="search" id="" class="search" value="Search for category ,product or brand" />
                    
                        
                    
                    <input type="submit" name="" value="Search" class="search_submit" />
                    
                </form>
            
            
                <input type="submit" name="" value="ADD TO CART" class="Add_Cart" />
                
                Items:0 | Total: Rs.0.00
                
                    <input type="submit" name="" value="Chekout" class="checkout_button" />
                
            
            
        
        
    
    

    

    

        
        
            
                
            
            
                 
                <form name="finder" action="">
                    Select Your Vehicle
                    
                </form>
                
                    
                        <label class="label_01">Make</label>
                    
                    <select class="select_finder">
                        <option>Make</option>
                        <option>Lorum</option>
                        <option>Lorum</option>
                    </select>
                    
                    
                
                
                    
                        <label class="label_01">Model</label>
                    
                    <select class="select_finder">
                        <option>Model</option>
                        <option>Lorum</option>
                        <option>Lorum</option>
                    </select>
                    
                    
                
                
                    
                        <label class="label_01">Year</label>
                    
                    <select class="select_finder">
                        <option>Year</option>
                        <option>2014</option>
                        <option>2013</option>
                    </select>
                    
                    
                
                
                    
                        <label class="label_01">Engine</label>
                    
                    <select class="select_finder">
                        <option>100cc</option>
                        <option>200cc</option>
                        <option>Lorum</option>
                    </select>
                    
                    
                
                
                    
                        <label class="label_01">Fuel</label>
                    
                    <select class="select_finder">
                        <option>Fuel</option>
                        <option>Lorum</option>
                        <option>Lorum</option>
                    </select>
                    
                    
                
                
                    <input type="submit" class="find_sub" value="Find" />
                
                <%--</form>--%>
            
        
        
        
            
                
            
            
                
                    
                        My Account
                            <%--
                                Register
                                Login
                            --%>
                        
                        What's New
                             
                                Cat 1
                                Cat 2
                            
                        
                        Specials
                        Support
                        Fix My car
                        About Us
                        Contact Us
                    
                
                Car Parts
                Accessories
                Tools
                Batteries
                Engine Oil
                Summer
            
            
        
    

    
    

    
        <form id="form1"  runat="server" method="post">
            
        </form>
    

    
    
        
            
                
                    
                        Information
                    
                    
                        Our Offers
                    
                
                
                    
                        Your Account
                    
                    
                        
                            Get In Touch 
                        
                    
                
            
            
        
        
            
                
                    About Us
                    Sitemap
                    Contact Us
                    Terms & Conditions
                    Refund Policy
                
            
            
                
                    Whats New?
                    Top Sellers
                    Specials
                    Categories
                    Review
                
            
            
                
                    My Account
                    Register
                    Add to cart
                    Support
                    Locations
                
            
            
                
                    
                         
                             
                                 
                                    
                
                Subscribe to Newsletter
                
                    <input type="text" name="search" id="" class="search" value="you@lorum.com" />
                    <input type="submit" name="" value="Subscribe" class="search_submit" />
                
            
        
    
              
    
        

        
    

</body>
</html>
Posted
Updated 7-Oct-14 8:46am
v3
Comments
Torakami 7-Oct-14 14:47pm    
I tried to post properly ... but for some reason few elemnts are not coming on this page .. Please correct my post .. Thanks

1 solution

XML
You can have multiple form on a webforms page, but only 1 can have the runat-"server' attribute and the runat="server" form cannot have any nested forms. One option that might work for you:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled</title>
</head>
<body>
    <div id="header>
        <h1>My Site</h1>
        <form id="SearchForm" action="search.aspx" method="post">
            <!--your search form html inputs (on server controls)-->
        </form>
    </div>

    <!-- the standard webforms form used for server controls etc-->
    <form id="form1" runat="server">

            <asp:ContentPlaceHolder ID="SearchBody" runat="server">
            </asp:ContentPlaceHolder>

    </form>
</body>
</html>
 
Share this answer
 

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


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