Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7897495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:10:51+00:00 2026-06-03T08:10:51+00:00

my master page is inside a form runat=server like this: <body> <form id=Form1 runat=server>

  • 0

my master page is inside a form runat=”server” like this:

<body>
    <form id="Form1" runat="server">
         <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
    </form>
</body>

In one of my pages I added a textarea, a button (html controls, not ASP’s), and some javascript code like this:

<textarea id="ContentTextArea" class="ContentTextArea" rows="2" cols="20"></textarea>
<button id="ClearButton" class="Button2" onclick="ClearButtonClick();">CLEAR</button>

    <script type="text/javascript">
        function ClearButtonClick() {
            document.getElementById("ContentTextArea").value = "";
        }
    </script>

I want the javascript code (which is clearing the textarea text) to run when the client click on the “clear” button without sending a request to the server, but because I have <form id="Form1" runat="server"> in the master page the button submit the data to the server and the page is reloaded.

I must have <form id="Form1" runat="server"> in my master page, but I also want to use JavaSctipt in my code that will run on the client side.

Thanks

EDIT:

my master page is:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head id="Head1" runat="server">
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="Form1" runat="server">
        <div class="header">
             <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
                        <asp:MenuItem NavigateUrl="~/ContactUs.aspx" Text="Contact Us"/>
                    </Items>
                </asp:Menu>
            </div>

            <div class="loginDisplay">
                <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
                    <AnonymousTemplate>
                        [ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
                    </AnonymousTemplate>
                    <LoggedInTemplate>
                        Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
                        [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
                    </LoggedInTemplate>
                </asp:LoginView>
            </div>
        </div>
        <div class="clear">
        </div>

        <div class="main">
        <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
        </div>

        <div class="footer">
            <p>GH Electronics © 2012. All Rights Reserved.</p>
        </div>

    </form>
    <input type="button" onclick="window.location = '/WareHouse/ContactUs.aspx';" value="avi"/>
    <script type="text/javascript">

           function ClearButtonClick() {
            document.getElementById("ContentTextArea").value = "";
            return false;
        }
    </script>
</body>


</html>

and my contact us form is:

<img alt="Contact Us" src="Images/contact_us.gif" style="float:left;"/>

<p class="contactUs" runat="server">CONTACT US</p>
<label>Full Name:</label>
<asp:TextBox class="FullNameTextBox" runat="server" />
<br /> <br />
<label>Phone Number:</label>
<asp:TextBox class="PhoneNumberTextBox" runat="server" />
<br /> <br />
<label>Email:</label>
<asp:TextBox class="EmailTextBox" runat="server" />
<br /> <br />
<label>Subject:</label>
<asp:TextBox class="SubjectTextBox" runat="server" />
<br /> <br />
<label>Content:</label>
<textarea id="ContentTextArea" class="ContentTextArea" rows="2" cols="20"></textarea>
<br /> <br />
<asp:Button ID="SendButton" class="SendButton" Text="SEND" runat="server" />


<button id="ClearButton" class="Button2" onclick="ClearButtonClick();">CLEAR</button>

<script type="text/javascript">

      function ClearButtonClick() {
       document.getElementById("ContentTextArea").value = "";
       return false;
   }

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:10:52+00:00Added an answer on June 3, 2026 at 8:10 am

    Think this should do it:

    <button id="ClearButton" class="Button2" onclick="javascript:ClearButtonClick();return false;">CLEAR</button>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I applied this master page to two files..one inside the same folder(file1.aspx) as
I have a web application in Asp.Net. I've created my master page and inside
I have the following markup inside a master page <html xmlns=http://www.w3.org/1999/xhtml > <head runat=server>
The Scenario I have an ASP.Net Web Project that uses a master page. This
I am implementing Javascript Validation on an ASP.Net page that is inside a Master
The master page currently looks like this: (No, I don't work for Google. The
My form-runat-server is inside of a masterpage, and I noticed the form id was
Im having a master page form which i validate. I add code inside the
In a Master page, I have this.... <ul id=productList> <li id=product_a class=active> <a href=>Product
I have a master page called SampleMaster.master and this page contains a Repeater control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.