Yes the field is not found. The field should be autogenerated and it is not. The question is what do I need to do to correct this.
The problem shows up after adding a form based on a master form. I've added no code at that point.
I noticed the problem in a form that I did add code, so I added a formwith none of my code to see if it was my code in the form or something else. Turns out the problem is not with the code on the form I was working on since it shows up in a newly created
form with no modifications. Not sure where to look to resolve this.
Microsoft JScript runtime error: Unable to get value of the property 'value': object is null or undefined
According to the description, it means document.getElementById("MainContent_MainContent_hfMessage") is null. You can't find the control by this ID. In order to resolve your issue, you can try to resolve it using the two methods as follows:
1. Try to use F12 to check the html element and find the id of the control. Then modify the id in the method document.getElementById.
2. Set the ClientIDMode as static. Using it, the ClientID value is set to the value of the ID property. If the control is a naming container, the control is used as the top of the hierarchy of naming containers for any controls that it contains.
Please see the demo below:
mgerber
0 Points
5 Posts
Problem with autogenerated JScript on Web Page
Dec 21, 2012 07:54 PM|LINK
Getting the following error after adding an item(web page based on master) and not yet having added any code:
Microsoft JScript runtime error: Unable to get value of the property 'value': object is null or undefined
This is the autogenerated code involved:
function message() {
if (document.getElementById("MainContent_MainContent_hfMessage").value.length > 0) {
alert(document.getElementById(
"MainContent_MainContent_hfMessage").value);
}
}
What is not getting autogenerated is the hiddenfield with the related Id.
Don't know what to do to fix this. Any suggestions would be appreciated.
abhij1987
Member
24 Points
7 Posts
Re: Problem with autogenerated JScript on Web Page
Dec 22, 2012 08:48 AM|LINK
Hi,
It is difficult to tell you from your question,
can you share your code.
the problem may be related to your hidden field control, it is not found during rendering
mgerber
0 Points
5 Posts
Re: Problem with autogenerated JScript on Web Page
Dec 22, 2012 08:47 PM|LINK
Yes the field is not found. The field should be autogenerated and it is not. The question is what do I need to do to correct this.
The problem shows up after adding a form based on a master form. I've added no code at that point.
I noticed the problem in a form that I did add code, so I added a formwith none of my code to see if it was my code in the form or something else. Turns out the problem is not with the code on the form I was working on since it shows up in a newly created form with no modifications. Not sure where to look to resolve this.
Catherine Sh...
All-Star
23373 Points
2490 Posts
Microsoft
Re: Problem with autogenerated JScript on Web Page
Dec 26, 2012 01:36 AM|LINK
Hi,
According to the description, it means document.getElementById("MainContent_MainContent_hfMessage") is null. You can't find the control by this ID. In order to resolve your issue, you can try to resolve it using the two methods as follows:
1. Try to use F12 to check the html element and find the id of the control. Then modify the id in the method document.getElementById.
2. Set the ClientIDMode as static. Using it, the ClientID value is set to the value of the ID property. If the control is a naming container, the control is used as the top of the hierarchy of naming containers for any controls that it contains. Please see the demo below:
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> <script type="text/javascript"> function message() { if (document.getElementById("MainContent_MainContent_hfMessage").value.length > 0) { alert(document.getElementById("MainContent_MainContent_hfMessage").value); } } </script> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:TextBox ID="MainContent_MainContent_hfMessage" ClientIDMode="Static" runat="server" Text="test"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="message()" /> </asp:Content>Best wishes,
Feedback to us
Develop and promote your apps in Windows Store