Retrieve textbox value while using master page concept
-
Hi, I am using master page and i inherited a aspx page and wrote html code inside asp:Content. I wrote a javascript code to get a textbox value for validation document.getElementById("txt_Amount").value, but i could not retrieve the value. Can any one say what i am doing wrong.
-
Hi, I am using master page and i inherited a aspx page and wrote html code inside asp:Content. I wrote a javascript code to get a textbox value for validation document.getElementById("txt_Amount").value, but i could not retrieve the value. Can any one say what i am doing wrong.
Where is your textbox ? in master page or content page ? Take view source of the page and check provided textbox name is correct.
-
Hi, I am using master page and i inherited a aspx page and wrote html code inside asp:Content. I wrote a javascript code to get a textbox value for validation document.getElementById("txt_Amount").value, but i could not retrieve the value. Can any one say what i am doing wrong.
Almost certainly you do not have a control called txt_Amount. That may be the ID on the server, but a more complex name is generated on the client. The way to access it is to insert script along the lines of: var txtAmountId = '<%=txt_Amount.ClientID%>'; in your ASPX, and then do document.getElementById(txtAmountId) I'd still regard it as poor form to tack the .value on the end without first checking if the call returned something. The quick way here is to look at your page source to see what the Id is, then you'd see where the problem lies. Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at
-
Where is your textbox ? in master page or content page ? Take view source of the page and check provided textbox name is correct.
Textbox is in content page only, i tried this code too but not working. I saw view source i noticed the name change so i took and tried with that name. function check_user() { var str = document.getElementById('ctl00_ContentPlaceHolder1_txtUsername').value; }
-
Textbox is in content page only, i tried this code too but not working. I saw view source i noticed the name change so i took and tried with that name. function check_user() { var str = document.getElementById('ctl00_ContentPlaceHolder1_txtUsername').value; }
Did you read my reply ?
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Did you read my reply ?
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Textbox is in content page only, i tried this code too but not working. I saw view source i noticed the name change so i took and tried with that name. function check_user() { var str = document.getElementById('ctl00_ContentPlaceHolder1_txtUsername').value; }
So is it working ? Christian's suggestion is the good one than this
-
This is how i have declared my textbox asp:TextBox ID="txtUsername" runat="server" CssClass="textBox" Width="200px" -- modified at 6:41 Thursday 25th October, 2007
OK, I take that to mean you didn't read my reply. The name of your textbox is irrelevant, my solution will work whatever you call it.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
So is it working ? Christian's suggestion is the good one than this