Click here to Skip to main content
15,886,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
XML
<asp:DropDownList ID="ddlManufaturemonth" runat="server" AutoPostBack="true" CssClass="select_box"
                                                               Width="80px"
                                                               onselectedindexchanged="ddlManufaturemonth_SelectedIndexChanged" onchange="javascript:return ValidateMonthandYear(this);">
                                                           </asp:DropDownList>

in this only one event is firing that is on change i want fire the both here selected change is not firing.Could any one help me


Regards,
Rahul.
Posted
Comments
Harshil_Raval 17-Sep-13 9:06am    
where is your javascript function ValidateMonthandYear?
naveen pallela 17-Sep-13 9:08am    
function ValidateMonthandYear() {
debugger;
var monthformat = { 'Jan': 01, 'Feb': 02, 'Mar': 03, 'Apr': 04, 'May': 05, 'Jun': 06, 'Jul': 07, 'Aug': 08, 'Sep': 09, 'Oct': 10, 'Nov': 11, 'Dec': 12 };
document.getElementById('<%=lblDateofPurchaseValidation.ClientID%>').innerHTML = '';
document.getElementById('<%=lblMonthandYearofManufacturingvalidation.ClientID%>').innerHTML = '';

//this is the selected Date
var Manufyear = document.getElementById('<%=ddlManufatureyear.ClientID%>').value
var Manufmonth = document.getElementById('<%=ddlManufaturemonth.ClientID%>').value
var ManufDay = document.getElementById('<%=ddlManufatureDay.ClientID%>').value
if (Manufyear != "0" && Manufmonth != "0" && ManufDay != "0") {
var date = Manufyear - +Manufmonth - +ManufDay;
}
else {
return false;
}
phil.o 17-Sep-13 9:29am    
1) var date = Manufyear +" - "+Manufmonth+" - "+ManufDay; => you assign this variable but you do not use it
2) As it has been told to you, you have to return true if your function succeeds
Harshil_Raval 17-Sep-13 9:12am    
It looks good. try to add return true; in if condition. Are you sure it is going in if condition, not in else.
naveen pallela 17-Sep-13 9:20am    
its not the problem with javascript function i want 2 fire both the events but selected chaged is not firing when i keep the on change funtion.when i remove the on change its calling the selected changed event but i want 2 check the valiadtion i need to write on change.....

The onchange clientside event disables the serverside event.

You can do a postback from your javascript function as the follows:
JavaScript
<script language="Javascript">
__doPostBack('__Page', 'MyCustomArgument');
</script></script>


And here is an explanation:
How to call Postback from Javascript[^]
 
Share this answer
 
v2
... OK, try the following javascript and let me know how you get on?

JavaScript
function ValidateMonthandYear() {
 debugger;
 var bReturn=true;
 var monthformat = { 'Jan': 01, 'Feb': 02, 'Mar': 03, 'Apr': 04, 'May': 05, 'Jun': 06, 'Jul': 07, 'Aug': 08, 'Sep': 09, 'Oct': 10, 'Nov': 11, 'Dec': 12 };

 document.getElementById('<%=lblDateofPurchaseValidation.ClientID%>').innerHTML = '';
 document.getElementById('<%=lblMonthandYearofManufacturingvalidation.ClientID%>').innerHTML = ''; 

 //this is the selected Date 
 var Manufyear = document.getElementById('<%=ddlManufatureyear.ClientID%>').value ;
 var Manufmonth = document.getElementById('<%=ddlManufaturemonth.ClientID%>').value;
 var ManufDay = document.getElementById('<%=ddlManufatureDay.ClientID%>').value;

 if (Manufyear != "0" && Manufmonth != "0" && ManufDay != "0") {
     var date = Manufyear - +Manufmonth - +ManufDay; 
 }
 else { 
     bReturn = false; 
 }

 return bReturn;
}
 
Share this answer
 

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