interviews.dotnetthread.com

↑ Grab this Headline Animator

Monday, April 20, 2009

How to call Javascript function on onchange event of Dropdownlist before server side event handler is called.

To call Javascript function on onchange event of Dropdownlist before server side event handler for SelectedIdexChanged event is called.

This is some what tricky as mentioning onchange = "return function(this);" in .aspx page will not work properly.

In this case we need to add 'if' codition as below

in .aspx page for dropdown list mention onchange as


onchange = "if (!confirmSubmit()){return};"


or else you can add attributes for dropdownlist as below


Dropdownlist1.Attributes.Add(
"onchange", "if (!confirmSubmit()){return};");

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles