hi
I have one user control to pick the date which utilizes ajax calendar extender. Also it has javascript validation for checking date format. Control is working fine when its visibility is true in loading time. But giving javascript error if i am making it visible with a button (server control) click.
Below is the javascript function to checking the date
txtDate.Attributes.Add("onblur", "javascript:ValidateDate('" & txtDate.ClientID & "');")
objStringBuilder.AppendLine("function ValidateDate(d) ")
objStringBuilder.AppendLine(" { ")
objStringBuilder.AppendLine(" var t = document.getElementById(d);")
objStringBuilder.AppendLine(" if (t.value.toString() != "")")
objStringBuilder.AppendLine(" {")
objStringBuilder.AppendLine(" if ( isDate(t.value.toString()) == true )")
objStringBuilder.AppendLine(" {")
objStringBuilder.AppendLine(" return true;")
objStringBuilder.AppendLine(" }")
objStringBuilder.AppendLine(" else")
objStringBuilder.AppendLine(" { ")
objStringBuilder.AppendLine(" alert("Please enter valid date in dd/mm/yyyy format");")
objStringBuilder.AppendLine(" t.value = "";")
objStringBuilder.AppendLine(" t.focus();")
objStringBuilder.AppendLine(" return false;")
objStringBuilder.AppendLine(" }")
objStringBuilder.AppendLine(" } ")
objStringBuilder.AppendLine(" } ")
while making visible and onblur it is giving error at
txtDate.Attributes.Add("onblur", "javascript:ValidateDate('" & txtDate.ClientID & "');")
"
line. The cause i think control's id is not getting passed while it making visible runtime. But working fine if the visibility is true during the loading.
please help
thanks Anto