473,320 Members | 1,936 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 in usercontrol

Hi

How do you refer from you webpage to a usercontrol which contains a n html
control with javascript?

usercontrol contains:

<input id="tb1" name="tb1" type=text>
webform Form1 tries to refer to tb1:

<INPUT style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 72px"
type="button" value="Button"
onclick="javascript:if(document.Form1['uc:tb1'].value =='1')alert('No
Good');">

how do you refer to the input control id="tb1"?
ch J.
Nov 19 '05 #1
2 1967

"Jimmy" wrote:
Hi

How do you refer from you webpage to a usercontrol which contains a n html
control with javascript?

usercontrol contains:

<input id="tb1" name="tb1" type=text>
webform Form1 tries to refer to tb1:

<INPUT style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 72px"
type="button" value="Button"
onclick="javascript:if(document.Form1['uc:tb1'].value =='1')alert('No
Good');">

how do you refer to the input control id="tb1"?
ch J.


you may want to try:

document.all["uc:tb1"].value

or

document.forms[0]["uc:tb1"].value

if your input is running at the server, you can get the unique id and
reference at it as:

document.forms[0].tb1uniqueID.value

Let me know if this was helpful for you.

Regards,
Cesar

Nov 19 '05 #2
Cesar

I ll give you the complete code, I have a userobject with an htmlcontrol tb1
and server control tb1. When I try to refer to those controls from my
webform
only the asp control works. The question is how to refer to the html one?

usercontrol:

<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="WebUserControl2.ascx.cs"
Inherits="javascriptusercontrol.WebUserControl2"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<input id="tb1" name="tb1" type="text" value="1">
<asp:TextBox id="tb2" runat="server">2</asp:TextBox>

webform

<%@ Register TagPrefix="uc1" TagName="WebUserControl2"
Src="WebUserControl2.ascx" %>
<%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false"
Inherits="javascriptusercontrol.WebForm3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm3</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<uc1:WebUserControl2 id="uc" runat="server"></uc1:WebUserControl2>
<input style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 56px"
onclick="javascript:if(document.Form1['uc:tb1'].value =='1')alert('got
ya!');"
type="button" value="Get value html control"> <input style="Z-INDEX:
101; LEFT: 16px; POSITION: absolute; TOP: 88px"
onclick="javascript:if(document.Form1['uc:tb2'].value =='2')alert('got
ya!');"
type="button" value="Get value asp textbox">
</form>
</body>
</HTML>

cheers

Jimmy
"Cesar" <Ce***@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...

"Jimmy" wrote:
Hi

How do you refer from you webpage to a usercontrol which contains a n html control with javascript?

usercontrol contains:

<input id="tb1" name="tb1" type=text>
webform Form1 tries to refer to tb1:

<INPUT style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 72px"
type="button" value="Button"
onclick="javascript:if(document.Form1['uc:tb1'].value =='1')alert('No Good');">

how do you refer to the input control id="tb1"?
ch J.


you may want to try:

document.all["uc:tb1"].value

or

document.forms[0]["uc:tb1"].value

if your input is running at the server, you can get the unique id and
reference at it as:

document.forms[0].tb1uniqueID.value

Let me know if this was helpful for you.

Regards,
Cesar

Nov 19 '05 #3

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

Similar topics

2
by: balu | last post by:
i created a user control for contact information. this control has contact name country etc and also phone number. all these are text boxes. My problem is for phone number i should give 3 text...
2
by: Carlo Marchesoni | last post by:
I have a UserControl that builds a Tree-View Menu using Javascript. This UC does not run as a ServerControl Then, in every aspx page I include this UC. Everything works perfect, except that if I...
5
by: Lau Lei Cheong | last post by:
Hello, I'm writing a usercontrol to be included in my project. The usercontrol have a few javascript function to do the client-side tasks. However, the controls on the usercontrol seems to...
1
by: billy | last post by:
Ok, here's the situation... I have a user control that contains two textboxes (one for a from date/time and one for a to date/time) and two image buttons. The user control itself is supposed to...
5
by: tshad | last post by:
I get an error when running my Javascript inside my UserControl. It works fine if I put the UserControl Data directly in my Web Page. The stripped down code is: <script language=javascript>...
0
by: jonathan.beckett | last post by:
I have been working on a client project recently that is using winforms ..NET user controls within web pages in Internet Explorer, and need to find out how to make the user control communicate back...
0
by: acadam | last post by:
Hi, I have an userControl .ascx with a gridView control. One of the columns is a TemplateField with an HyperLink control. On the Row_DataBound event, I am checking that one of the other columns...
0
by: Jesper Lund Stocholm | last post by:
I have problems with sending javascript to the client from a dynamically loaded usercontrol. I have a single page that dynamically loads controls into a table cell in a HTML-table. For one of...
2
by: jyanmin.fang | last post by:
Hi, In my current project, I need to embed an .NET winform usercontrol in the aspx page (via <Objecttag). This winform usercontrol has an event called DoEvent (void DoEvent()). This winform...
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...
0
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...
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)...
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.