I have asp.net application having page with asp.net wizard control. this wizard control having the textbox controls. I want to access this textbox value in javascript. where as i tried to access this text box control by this :
var originalPrice2 = document.getElementById('<%= mytextbox.ClientID %>').value;
or
var originalPrice2 = document.getElementById('mytextbox').value;
but not getting any value .
where as I started firebug I found engine dynamically allocating the id to textbox control as "ctl00_ContentPlaceHolder1_Wizard1_mytextbox"
and when i tried to get value of text box using this generated id.
var originalPrice2 = document.getElementById('<%= ctl00_ContentPlaceHolder1_W开发者_高级运维izard1_mytextbox.ClientID %>').value;
but getting exception :
The name 'ctl00_ContentPlaceHolder1_Wizard1_mytextbox' does not exist in the current context
Why should be this? my html is exactly same what i explained.
Try using jQuery:
alert( $("input:text[id$='mytextbox']").val());
OR
var originalPrice2 = document.getElementById('ctl00_ContentPlaceHolder1_Wizard1_mytextbox').value;
精彩评论