submiting with validation controls seem to have two onclick event?

arun_mrk

Well-known member
Joined
Apr 1, 2003
Messages
51
Location
beijing
I have web page where i had used some validation control and i had also written javascript validation for few validations.

Now when i submit i dont see my validation routine been called.

The reason is two onclick exists when source is viewed
it appear as

<code>
<input type="submit" name="btnSearch" value="Click here" onclick="if (typeof(Page_ClientValidate) == function) Page_ClientValidate(); " language="javascript" id="btnSearch" class="SButton" onclick="return ValidateDate();" />
</code>

where validateDate() is javascript routine written by me, which never gets executed

how to over come this issues to make both fire?
 
I not quite sure about your code, why there are 2 onClick event in the same control? You want to call 2 functions in onClick event?
 
i will make clear

in my html design i had used
<code>
<asp:button id="btnSearch" runat="server" CssClass="SButton" Text="Click here, To Search"></asp:button>
</code>

add thru codebehind i added

btnSearch.Attributes.Add("onclick","return ValidateDate();");


so in the view source code(which i had pasted earlier thread was generated automatically by the browser) it appears as
two onclick
 
I am just curious why you need validation control and your own validation? why dont just use either one?

I dont think so system will fire 2 times on the same event, thats why your validation not fire.
 
there are lot of controls on my web page.

For date i have three drop down list ( year,mon,day).


To validate drop down list, whether the entered(chosen) date is valid, i had written my own validation for this.

For other textbox controls i had used required field validator and some other validation controls.
 
Since you write your own validation, why dont just validate before user submit the page? One function link to all the other functions.

If you use validation control for one of your web controls, then you should not use your own control again for that web control, since it is already validated... Do you understand what I mean?
 
Back
Top