User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 428,574 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,616 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 15567 | Replies: 8
Reply
Join Date: Jul 2004
Posts: 2
Reputation: dsilander is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dsilander dsilander is offline Offline
Newbie Poster

.net validation/javascript conflict

  #1  
Jul 15th, 2004
Hi

I would like to run a javascript function (to confirm deletion) from a web control (asp:button) before posting back to the same page.

I have read about how to do this in several places (mybutton.attributes.add... )

However, the fact that I have asp.net validation controls on my page means that I automatically end up with two onclick attributes in my HTML and the javascript function is not called.

Has anybody encountered (and hopefully solved) this?

Thanks in advance

Duncan
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2004
Posts: 8
Reputation: siddartha_pal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
siddartha_pal siddartha_pal is offline Offline
Newbie Poster

Re: .net validation/javascript conflict

  #2  
Jul 20th, 2004
Originally Posted by dsilander
Hi

I would like to run a javascript function (to confirm deletion) from a web control (asp:button) before posting back to the same page.

I have read about how to do this in several places (mybutton.attributes.add... )

However, the fact that I have asp.net validation controls on my page means that I automatically end up with two onclick attributes in my HTML and the javascript function is not called.

Has anybody encountered (and hopefully solved) this?

Thanks in advance

Duncan

Hi
use custom validator for the purpose.

pls get back to me if its not solved.

thnks n regards
siddartha
Reply With Quote  
Join Date: Feb 2002
Location: New York
Posts: 862
Reputation: Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light 
Rep Power: 12
Solved Threads: 15
Moderator
Tekmaven's Avatar
Tekmaven Tekmaven is offline Offline
The C# Man, Myth, Legend

Re: .net validation/javascript conflict

  #3  
Jul 20th, 2004
siddartha_pal, I think you misunderstand the issue.

dslander, what type of validation controls are you using? Can you just incorporate your onclick logic to the javacript for the validation?
-Ryan Hoffman

ASP.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
Reply With Quote  
Join Date: Jul 2004
Posts: 2
Reputation: dsilander is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dsilander dsilander is offline Offline
Newbie Poster

Re: .net validation/javascript conflict

  #4  
Jul 20th, 2004
I am using both required field validators and regular expression validators.

I could probably work around the issue by using custom validators but I would rather do it with the controls I have if at all possible (it's easier & tidier).

If I resort to using custom validators then I'd be as well coding the whole thing (validation & confirmation) in the javascript onclick event. I could do this but would rather use the more concise & specific .net controls if I can.
Reply With Quote  
Join Date: Jun 2004
Posts: 8
Reputation: siddartha_pal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
siddartha_pal siddartha_pal is offline Offline
Newbie Poster

Re: .net validation/javascript conflict

  #5  
Jul 27th, 2004
Originally Posted by dsilander
I am using both required field validators and regular expression validators.

I could probably work around the issue by using custom validators but I would rather do it with the controls I have if at all possible (it's easier & tidier).

If I resort to using custom validators then I'd be as well coding the whole thing (validation & confirmation) in the javascript onclick event. I could do this but would rather use the more concise & specific .net controls if I can.


hi there
I am not getting how u have two onclick attributes? and why u need two onclick there.
I think when your javascript function will return true only then server side event handler should execute. Seems I am anot able to get u properly.

thnks
Reply With Quote  
Join Date: Jul 2004
Posts: 2
Reputation: haniebrahim is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
haniebrahim haniebrahim is offline Offline
Newbie Poster

Re: .net validation/javascript conflict

  #6  
Jul 28th, 2004
I have the same probleb with javasecript code using custom validator
i tried to make the return to true but it failed too
so anyone can give me a hand on this problem or send me a Sample
Reply With Quote  
Join Date: Sep 2004
Posts: 1
Reputation: Hardcoder is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Hardcoder Hardcoder is offline Offline
Newbie Poster

Re: .net validation/javascript conflict

  #7  
Sep 15th, 2004
I came across this problem too.

This simple solution is probably enough:
- disable validation on your delete button (causesvalidation="false")
- add the 'onclick' event as normal using the Attributes property in your code behind file.

Setting causesvalidation to false means .net won't put in it's own 'onclick' method.

For my application, the delete doesn't require any validation (it just deletes the current item), and I think this will apply in the majority of situations. Hopefully those where some form of validation is required, maybe it's simple enough to write custom jscript.

I think it's a bit of a short-fall in the current webforms implementation.

Troy.
Reply With Quote  
Join Date: May 2005
Posts: 1
Reputation: cmert is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cmert cmert is offline Offline
Newbie Poster

Re: .net validation/javascript conflict

  #8  
May 27th, 2005
Same problem happened to me and I've found a solution..

Now HERE IS MY SOLUTION;
1) Change EnableClientScript settings to FALSE for each validation rule. (Custom or Regular doesn't matter)
This will post the page back and validate fields at server level.

2) Place your code which you would like to process, if all fields are valid to between followin if statement;
if Page.IsValid then
'Your code
end if

And this worked fine for me, I am positive it is going to work for you too,..

Thanks,
Mert..
Reply With Quote  
Join Date: May 2007
Posts: 1
Reputation: airyce is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
airyce's Avatar
airyce airyce is offline Offline
Newbie Poster

Re: .net validation/javascript conflict

  #9  
May 31st, 2007
Originally Posted by cmert View Post
Same problem happened to me and I've found a solution..

Now HERE IS MY SOLUTION;
1) Change EnableClientScript settings to FALSE for each validation rule. (Custom or Regular doesn't matter)
This will post the page back and validate fields at server level.

2) Place your code which you would like to process, if all fields are valid to between followin if statement;
if Page.IsValid then
'Your code
end if

And this worked fine for me, I am positive it is going to work for you too,..

Thanks,
Mert..


I am having that same problem too regarding with the .net validator and javascript ...

after i have try your suggestions it didn't work fine for me....

cause im using a java-based calendar and a required field validator
although the calendar is working but whenever it clicks.. for example clicking the year (or month) it skips by 3 , by 4 , by 5 and so on....

and whenever i checked the error.. this is what i've got

----length is 'null' or not an object

how come that is null? and why it is null?

can anyone knows why are those two conflict?

???
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 11:18 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC