Click here to Skip to main content
15,917,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in asp.net appliaction i am getting autogenrated javascript event which i realy dont want. i have a button named login because of this autogenrated javascript events my client is not able to login which is genrated automatically and i realy dont know why this is happing

Asp.net Button in custome user Control .ascx file

C#
<asp:Button ID="cmdLogin" runat="server" Text="Login" CssClass="Footer_button" 
 CommandName="login"  CausesValidation="True" />


As you can see there is no event at all in the button but when i run my application in any browser it render the autogenrated event

AutoGenrated javascript event

JavaScript
<input name="ctl00$header1$slidingpanel1$Login1$cmdLogin" value="Login" id="ctl00_header1_slidingpanel1_Login1_cmdLogin" class="Footer_button" type="submit"
onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$header1$slidingpanel1$Login1$cmdLogin", "", true, "", "", false, false))">


i want to get rid of this auto genrated onclick event and also it is rendring an onsubmit event in aspnetform in browser

C#
<form name="aspnetForm" method="post" action="default.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">

i want to get rid of this autogenrated javascript event Kindly help me regarding this issue as other can also have this problem Thank in advance
Posted
Comments
Timberbird 24-Oct-13 9:36am    
Hey, if you need a simple button that doesn't cause a postback, why using ASP.NET Button? Use HtmlInputButton control or insert plain html markup like <input type="button" value="Login" /> .
I believe, though, that if you are implementing login functionality, then postback is required (since usually login logic is run on server). And in this case JavaScript is inserted correctly, since your button is a server control which additionally has CommandName and CausesValidation attributes
Sergey Alexandrovich Kryukov 24-Oct-13 22:29pm    
Why did you allow something to auto-generate without your consent? Anyway, it's always possible to remove (say, manually), but it's always better to take a step back.
—SA

Acutlly i am using Asp.net login control and it`s event Authenticate from code behind that`s why i dont need to put click event on button because this button is under login control and haddling the login authentication by asp.net login control event "Authenticate" so no need to put any event on button but login control from code behind

C#
<asp:login id="Login1" runat="server" xmlns:asp="#unknown">
                <layouttemplate>
                    <label for="log">User Name: </label>
                    <asp:textbox id="Username" runat="server"></asp:textbox>

                    <label for="pwd">Password: </label>
                    <asp:textbox id="password" textmode="Password" runat="server"></asp:textbox>
                  // this is the Button where javascript event were rendered in browsre
                    <asp:button id="cmdLogin" runat="server" text="Login" commandname="login">
        CssClass="Footer_button" />                       
                </asp:button></layouttemplate>
 </asp:login>



This login Control is under custome Control file .ascx which i registered this control in Default.aspx page also there are more custome control in dafault page which i regestered in Default.aspx page like below

C#
<![CDATA[<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
    CodeFile="Default.aspx.vb" Inherits="_Default" Title="Minato Cars - Home Page" %>
<![CDATA[<%@ Register Src="~/Controls/CallRequest.ascx" TagName="CallRequest" TagPrefix="psc" %>
<![CDATA[<%@ Register Src="~/Controls/RequestACar.ascx" TagName="RequestACar" TagPrefix="psc" %>
<![CDATA[<%@ Register Src="~/Controls/Skype.ascx" TagName="Skype" TagPrefix="psc" %>
<![CDATA[<%@ Register Src="~/Controls/EmailInfo.ascx" TagName="EmailInfo" TagPrefix="psc" %>
<![CDATA[<%@ Register Src="~/Controls/QuickContact.ascx" TagName="QuickContact" TagPrefix="psc" %>
<![CDATA[<%@ Register Src="~/Controls/SearchByVehicleType.ascx" TagName="SearchByVehicleType" TagPrefix="psc" %>
<![CDATA[<%@ Register Src="~/Controls/SearchbyMake.ascx" TagName="SearchByMake" TagPrefix="psc" %>



(this is the main point to understand)

i had some asp.net validation in CallRequest.ascx & in QuickContact.ascx Custome Control. and the default page is using Masterpage..

As we all know whenever we use Asp.net Validation it render the javascript event _dopostback in browser with onsubmit event in form Or in asp.net aspnetform and some time it also render the onclick event on the button which type is onsubmit (type=onsubmit of button) that is why i was getting autogenrated javascript event due to asp.net validation. i have handeld it by using jQeury Server & client side validation without form and now it`s working..
 
Share this answer
 
v2
 
Share this answer
 
Comments
OriginalGriff 1-Jul-19 1:56am    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 6 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more!
Answering old questions can be seen as rep-point hunting, which is a form of site abuse. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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