473,463 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Object Require in JavaScript

Hi Team,

Am using java script in asp.net for input validation. When i run the below program it was throwing an exception Object expected. Please advice me where it was going wrong. Thanks in advance. i have attached the full code for your reference.
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2. function check()
  3. {
  4. if(document.getElementById('TextBox1').value=="")
  5. alert("enter username");
  6. }
  7. </script>
  8. <td class='list'><asp:TextBox  CssClass="text" ID="TextBox1" runat="server" ></asp:TextBox></td>
Query.txt
Jul 15 '10 #1
3 1557
Look at the rendered HTML by viewing the source of the page in the browser. Locate your textbox. I am guessing that the ID is not 'TextBox1', correct? If it isn't, you can do one of two things:

1. Use the ID that is generated by the .NET runtime. This isn't the best approach: if the structure of your page changes over time, the ID may also change.

2. Use this in your javascript code:
Expand|Select|Wrap|Line Numbers
  1. if(document.getElementById('<%=TextBox1.ClientID%>').value=="") 
  2.  
Jul 15 '10 #2
@Christopher Nigro
Hi Buddy,

i have tried as you mentioned. But still it was throwing the same error. Since am using master page the child page which inherits the master page. It was working fine in normal asp page. The issue was, when am using master page content place holder. Please help me.
Jul 16 '10 #3
Please show what you tried. I ran a simple test and it worked for me.
Jul 16 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Phil | last post by:
Hi, I want to access the features of a plugin without actually embedding it into a page. Is this possible? Eg The code to embed the object into a page is: <OBJECT...
54
by: tshad | last post by:
I have a function: function SalaryDisplay(me) { var salaryMinLabel = document.getElementById("SalaryMin"); salaryMinLabel.value = 200; alert("after setting salaryMinLabel = " +...
0
by: weichung[MCSD,MCDBA] | last post by:
Hi, I am currently having a .net Object whcih had been written in the code behind. However, I wish to avoid a round trip from the client to server (postback). Therefore I am wondering how could...
1
by: Anbu | last post by:
All, I'm developing an website using ASP .NET. I have developed a menu structure based on JavaScript. This JavaScript file is called by an UserControl to generate the menus. It works fine for...
4
by: andrei.csibi | last post by:
I've have a .NET Assembly, which is COM Visible. I would like to load objects from this assembly in javascript code. E.g. Assembly Book.dll has the class Book and I would like to use <script...
1
by: Saurabh | last post by:
i want to create a table dynamically. Right now what i am using is a string harcoded with the table structure with "<TD>"+values i want to fill in the table dynamically. and then padd this string...
6
by: MayBoy | last post by:
Hi There I am trying to use the Goto method of the Word ActiveX object. I am trying to open a document and go to a named bookmark. If I use this code in VB it works, so I'm sure the approach is...
7
by: Rob | last post by:
Hi, I'm getting an error on my login page when using Javascript session object. It works on the development server so I'm wondering if there is a setting in IIS to allow using sessions on the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.