473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

javascript error: "Object required"

Hi,

This code gives an javascript error: "Object required" and never let see the
Alert window.
in code-behind:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Hiddenfield1.value="end text"
end sub

in aspx file:

<asp:HiddenField ID="hd1" runat="server" value="beginning
text"></asp:HiddenField>
<asp:Button ID="Button1" OnClientClick="test()" runat="server"/>

<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById("hd1").value
alert(x)
}
</script>

Thanks
Phil
Mar 8 '07 #1
4 3078
Is the hd1 a part of any template or a content page or a user control? In
this case it will have a different id on the client. In any case you can
view the html source and check the actual id.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Phil" <ph**@sgnomail.dkwrote in message
news:e7*************@TK2MSFTNGP04.phx.gbl...
Hi,

This code gives an javascript error: "Object required" and never let see
the Alert window.
in code-behind:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Hiddenfield1.value="end text"
end sub

in aspx file:

<asp:HiddenField ID="hd1" runat="server" value="beginning
text"></asp:HiddenField>
<asp:Button ID="Button1" OnClientClick="test()" runat="server"/>

<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById("hd1").value
alert(x)
}
</script>

Thanks
Phil


Mar 8 '07 #2
"Phil" <ph**@sgnomail.dkwrote in message
news:e7*************@TK2MSFTNGP04.phx.gbl...
var x = document.getElementById("hd1").value
var x = document.getElementById("hd1").value
Mar 8 '07 #3
"Phil" <ph**@sgnomail.dkwrote in message
news:e7*************@TK2MSFTNGP04.phx.gbl...
var x = document.getElementById("hd1").value
var x = document.getElementById('<%=hd1.ClientID%>').value ;
Mar 8 '07 #4
Thank you guys, for replying.

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:Ol*************@TK2MSFTNGP04.phx.gbl...
"Phil" <ph**@sgnomail.dkwrote in message
news:e7*************@TK2MSFTNGP04.phx.gbl...
> var x = document.getElementById("hd1").value

var x = document.getElementById('<%=hd1.ClientID%>').value ;


Mar 8 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris Magoun | last post by:
I suddenly received an unexpected error in my project. I have been working on this project for some time without this issue. Nothing has changed in the form that caused the exception. A little...
18
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12,...
0
by: Martin Widmer | last post by:
Hello again! I have a datagridview control on my form and am using VS.Net 2005. One column is set up as combo box column, and when I try to set the datasource for that combobox column at design...
5
by: DaFallus | last post by:
I'm trying to write a somewhat simple page with dependent drop-down boxes. Unfortunately the entire page is written through PL/SQL so that makes it even more difficult for me to trouble shoot. I...
3
by: =?Utf-8?B?QmFkaXM=?= | last post by:
I'm doing a server side automation(I know it's bad but..) and its working fine locally and when accessing it from a remote machine using web browser is was giving me this error"Retrieving the COM...
11
by: narpet | last post by:
Hello all, I'm hoping somebody can help me with this. I have an app that I've been developing in MS Visual Studio 2005 Pro, C#. I have connectivity to a SQL server database. All of the sudden,...
2
by: =?Utf-8?B?U3dhcHB5?= | last post by:
hi, I am working on application in this i am using two files. In first (consider A) file i am calling the function of other file (consider B). In that function of file B i am calling the method...
3
by: Sarah | last post by:
Hi - Please be gentle. I am quite new to visual basic, but I have been going through tutorials and reading up. I found a code snippet on the internet that I wanted to see if I could re-purpose...
5
by: dotnetnovice | last post by:
Hi everybody actually i was trying to insert some records in to SQL server through C# Wndows Aplication and during that i face an error "Object reference not set to an instance of an object." and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.