HELP with unwanted javascript being added to my ASP.NET form?

Hi,

I am having some unwanted javascript added to only one of my forms and I cannot figure out why.  First this onsubmit gets added to my form tag:

<form id="SignUpForm" onsubmit="javascript:return WebForm_OnSubmit();" action="user.aspx" method="post">

Open in new window


And  this onclick event is being added to the Sign Up form's submit button:

onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl01", "", true, "", "", false, false))"

Open in new window


I don't want this though and I don't know why these snippets of code are being added (they don't get added to the other forms). Can someone tell me what this means?

http://auroriella.com/user.aspx#signup

FairyBusinessAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

amit_gCommented:
These are added by asp.net runtime. You must be using the server or html controls with runat="server". If you don't want to have these you won't be able to use built in functionality of asp.net. Remove the runat and these should go away. In that case you will have to process the submitted form yourself.
0
FairyBusinessAuthor Commented:
I have other forms with the runat=server and they don't have any of this added JavaScript and work as they r supposed to. . .
0
ddayx10Commented:
This page should by and large explain to you what is happening. By the end of the first page you will have 99% of your answer. If you read the whole thing it should become apprent.

http://dotnetslackers.com/articles/aspnet/UnderstandingASPNETValidationLibrary.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

amit_gCommented:
most of your pages don't have any input controls. Give us example of a page that has inputs and post the code for both that page and this page.
0
FairyBusinessAuthor Commented:
On this page, when you click on a tab the form for it is loaded into its matching section

http://auroriella.com/user.aspx

This page is technically the only page so far that as asp.net server forms on it.  It never has more than one on the page at once though.

The LoginForm and the NewPasswordForm both act the way they are supposed to (no added javascript)

This is how the page starts:

    <section id="login" class="tab">
        <form method="post" action="user.aspx" id="LoginForm" runat="server" visible="false">
            <label>Email<span class="red">*</span></label>
            <asp:TextBox id="loginEmail" value="" class="form-text" runat="server" />
            <label>Password<span class="red">*</span></label>
            <asp:TextBox id="loginPassword" value="" class="form-text" runat="server" />
            <br />
            <asp:Button text="Log In" class="form-submit" runat="server" OnClick="LogIn" />
        </form>
    </section>
    <section id="new_password" class="tab">
        <form method="post" action="user.aspx" id="NewPaswordForm" runat="server" visible="false">
            <label>Email Address<span class="red">*</span></label>
            <input type="text" name="retrieve-email" value="" class="form-text" />
            <br />
            <input type="submit" value="Submit" class="form-submit " />
        </form>    
    </section>
    <section id="signup" class="tab">
        <form method="post" action="user.aspx" id="SignUpForm" runat="server" visible="false">
            <article class="align-left">
            <label>First Name<span class="red">*</span></label>
            <asp:TextBox id="firstname" value="" class="form-text" ValidationGroup="Group1" runat="server" /><br />
            <label>Last Name<span class="red">*</span></label>
            <asp:TextBox id="lastname" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <!--<asp:RequiredFieldValidator ErrorMessage="This is required" runat="server" ControlToValidate="firstname" Display="dynamic" />-->
            <label>Email Address<span class="red">*</span></label>
            <asp:TextBox id="email" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <label>Password<span class="red">*</span></label>
            <asp:TextBox id="password" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <label>Re-enter Password<span class="red">*</span></label>
            <asp:TextBox id="repassword" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            </article>
            <article class="align-left">
            <label>Business Name<span class="red">*</span></label>
            <asp:TextBox id="business" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <label>Employer ID Number<span class="red">*</span></label>
            <asp:TextBox id="eid" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <label>Tax ID Number<span class="red">*</span></label>
            <asp:TextBox id="tid" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <label>Business Address<span class="red">*</span></label>
            <asp:TextBox id="address" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <details class="align-left city">
                <label>City<span class="red">*</span></label>
                <asp:TextBox id="city" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            </details>
            <details class="align-left state">
                <label>State<span class="red">*</span></label>
                <asp:TextBox id="state" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            </details>
            <details class="align-left zip">
                <label>Zip<span class="red">*</span></label>
                <asp:TextBox id="zip" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            </details>
            </article>
            <br />
            <asp:Button text="Sign Up" class="form-submit" runat="server" OnClick="SignUp" />
        </form>
    </section>

Open in new window


Here are the files that are loaded in their places:

login.aspx

        <form method="post" action="user.aspx" id="LoginForm" runat="server">
            <label>Email<span class="red">*</span></label>
            <asp:TextBox id="loginEmail" value="" class="form-text" runat="server" />
            <label>Password<span class="red">*</span></label>
            <asp:TextBox id="loginPassword" value="" class="form-text" runat="server" />
            <br />
            <asp:Button text="Log In" class="form-submit" runat="server" />
        </form>

Open in new window


new_password.aspx

        <form method="post" action="user.aspx" id="NewPaswordForm" runat="server">
            <label>Email Address<span class="red">*</span></label>
            <input type="text" name="retrieve-email" value="" class="form-text" />
            <br />
            <input type="submit" value="Submit" class="form-submit " />
        </form>    

Open in new window


signup.aspx  

        <form method="post" action="user.aspx" id="SignUpForm" runat="server">
            <article class="align-left">
            <label>First Name<span class="red">*</span></label>
            <asp:TextBox id="firstname" value="" class="form-text" ValidationGroup="Group1" runat="server" /><br />
            <label>Last Name<span class="red">*</span></label>
            <asp:TextBox id="lastname" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <!--<asp:RequiredFieldValidator ErrorMessage="This is required" runat="server" ControlToValidate="firstname" Display="dynamic" />-->
            <label>Email Address<span class="red">*</span></label>
            <asp:TextBox id="email" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <label>Password<span class="red">*</span></label>
            <asp:TextBox id="password" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <label>Re-enter Password<span class="red">*</span></label>
            <asp:TextBox id="repassword" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            </article>
            <article class="align-left">
            <label>Business Name<span class="red">*</span></label>
            <asp:TextBox id="business" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <label>Employer ID Number<span class="red">*</span></label>
            <asp:TextBox id="eid" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <label>Tax ID Number<span class="red">*</span></label>
            <asp:TextBox id="tid" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <label>Business Address<span class="red">*</span></label>
            <asp:TextBox id="address" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            <details class="align-left city">
                <label>City<span class="red">*</span></label>
                <asp:TextBox id="city" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            </details>
            <details class="align-left state">
                <label>State<span class="red">*</span></label>
                <asp:TextBox id="state" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            </details>
            <details class="align-left zip">
                <label>Zip<span class="red">*</span></label>
                <asp:TextBox id="zip" value="" class="form-text" ValidationGroup="Group1" runat="server" />
            </details>
            </article>
            <br />
            <asp:Button text="Sign Up" class="form-submit" runat="server" />
        </form>

Open in new window

0
FairyBusinessAuthor Commented:
I have kind of give up on identifying why C#/ASP.NET is adding extra javascript to only one of my forms in my tab menu, and now I am focusing on removing them dynamically.  I have tried these methods so far but with no luck:

        $(this).attr("onsubmit").empty();
        $(this).removeAttr("onsubmit");
        $(this).prop("onsubmit", null);
        $("input:submit", this).prop("onclick", null);
        $("input:submit", this).attr("onclick").empty();
        $("input:submit", this).removeAttr("onclick");

Open in new window


Does anyone know any other ways one can remove javascript with javascript??
0
FairyBusinessAuthor Commented:
Ah ok, I see now. It was all my validation stuff that added that javascript. I got rid of and it works now!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.