Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have txtIdentifierXml as hidden variable.

JavaScript
<INPUT id="txtIdentifierXml" style="Z-INDEX: 101; LEFT: 488px; WIDTH: 40px; POSITION: absolute; TOP: 176px; HEIGHT: 32px"
				type="hidden" size="1" name="txtIdentifierXml"  runat="server">


in my frmidentifier.aspx.vb i wrote javascript.

that is

VB
Me.RegisterClientScriptBlock("CloseMe_2", "<script language='javascript'>" & _
                    "alert(document.forms[0].txtIdentifierXml.value);" & _
                    " window.returnValue = document.forms[0].txtIdentifierXml.value;" & _
                    " </script>")


i get an error at the line of

JavaScript
"alert(document.forms[0].txtIdentifierXml.value);" 


error is :

VB
document.forms(...).txtIdentifierXml.value'
is null or not an object


please help me
Posted
Updated 5-Sep-12 18:31pm
v3
Comments
Member 7932936 6-Sep-12 1:36am    
i used like that

now iam getting object required

1 solution

The Best thing would be, view the source(html) before you register the script(comment it if you can) and see if you see any element name like txtIdentifierXml.

If your form has a name, then you can use it directly as:
<form name="myform" ...
then you can use:
JavaScript
document.myform.txtIdentifierXml


A your item is hidden you need little more tricky stuff there, ie to use clientID

document.getElementById('<%=txtIdentifierXml.ClientID %>').value


VB
Me.RegisterClientScriptBlock("CloseMe_2", "<script language="'javascript'">" & _
"var hidVal =document.yourformname.getElementById('<%=txtIdentifierXml.ClientID %>').value;" & _                    
"alert(hidVal);" & _
" window.returnValue = hidVal;" & _
" </script>")
 
Share this answer
 
v7
Comments
Member 7932936 6-Sep-12 1:00am    
i used my form name also.

i got same error
Kuthuparakkal 6-Sep-12 1:05am    
open your page and see source before you register your script. And see if you can find exactly the same element : txtIdentifierXml
Member 7932936 6-Sep-12 1:19am    
my page has only one txtIdentifierXml element
Kuthuparakkal 6-Sep-12 1:37am    
hidden filed is on server side you neeed to get client id of the filed to get the value in your javascript; solution updated.
Member 7932936 6-Sep-12 1:41am    
is there any solution?

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