why my javascript attribut dosent work in usercontrol ????
-
I got following scenario: User control placed on default.aspx page, in my user control i got a text box and "Submit" button is on my user control. Now i need to add the validat my text box (which is in user control) when user clicks "Submit" button then i should show error message. I need to do my validation on client side I tried it by adding an attribut to my button like this : BtnSave.Attributes.Add("onclick", "if (!ValidateSecActionType()) return false; "); then i wrote this code in codefront page : function ValidateSecActionType() { if(document.getElementById('txtSecActionTypeTitle').innerText == "1" ) { document.getElementById('AlertLbl').style.visibility = 'visible' ; return false; } return true; } now when i run my page i have an error like this : Object Required how can i do this ????????????? thanks alot....
-
I got following scenario: User control placed on default.aspx page, in my user control i got a text box and "Submit" button is on my user control. Now i need to add the validat my text box (which is in user control) when user clicks "Submit" button then i should show error message. I need to do my validation on client side I tried it by adding an attribut to my button like this : BtnSave.Attributes.Add("onclick", "if (!ValidateSecActionType()) return false; "); then i wrote this code in codefront page : function ValidateSecActionType() { if(document.getElementById('txtSecActionTypeTitle').innerText == "1" ) { document.getElementById('AlertLbl').style.visibility = 'visible' ; return false; } return true; } now when i run my page i have an error like this : Object Required how can i do this ????????????? thanks alot....
Could you share some more information about the error message, like when and where it occurs, and what code line it refers to? I don't know if this is the cause of the error, but: The innerText property is only available in Internet Explorer, and probably only in quirks mode. Use innerHTML instead.
--- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams
-
I got following scenario: User control placed on default.aspx page, in my user control i got a text box and "Submit" button is on my user control. Now i need to add the validat my text box (which is in user control) when user clicks "Submit" button then i should show error message. I need to do my validation on client side I tried it by adding an attribut to my button like this : BtnSave.Attributes.Add("onclick", "if (!ValidateSecActionType()) return false; "); then i wrote this code in codefront page : function ValidateSecActionType() { if(document.getElementById('txtSecActionTypeTitle').innerText == "1" ) { document.getElementById('AlertLbl').style.visibility = 'visible' ; return false; } return true; } now when i run my page i have an error like this : Object Required how can i do this ????????????? thanks alot....
go to view source, and check whether the, 'txtSecActionTypeTitle' is same or it is comming with some prefixfollowed with and underscore. eg: 'ctl00_txtSecActionTypeTitle'
Ravi Kant Srivastava (System Analyst) HandsOn Technology & Engineering Gurgaon (India) e-mail:ravikant@hte.co.in