473,788 Members | 2,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="javasc ript:if(documen t.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 1996

"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="javasc ript:if(documen t.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.va lue

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="Web UserControl2.as cx.cs"
Inherits="javas criptusercontro l.WebUserContro l2"
TargetSchema="h ttp://schemas.microso ft.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="WebUse rControl2"
Src="WebUserCon trol2.ascx" %>
<%@ Page language="c#" Codebehind="Web Form3.aspx.cs" AutoEventWireup ="false"
Inherits="javas criptusercontro l.WebForm3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm3 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<uc1:WebUserCon trol2 id="uc" runat="server"> </uc1:WebUserCont rol2>
<input style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 56px"
onclick="javasc ript:if(documen t.Form1['uc:tb1'].value =='1')alert('go t
ya!');"
type="button" value="Get value html control"> <input style="Z-INDEX:
101; LEFT: 16px; POSITION: absolute; TOP: 88px"
onclick="javasc ript:if(documen t.Form1['uc:tb2'].value =='2')alert('go t
ya!');"
type="button" value="Get value asp textbox">
</form>
</body>
</HTML>

cheers

Jimmy
"Cesar" <Ce***@discussi ons.microsoft.c om> wrote in message
news:7D******** *************** ***********@mic rosoft.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="javasc ript:if(documen t.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.va lue

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
1461
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 boxes. where textbox1 is for area code,textbox2 is for exch and textbox3 is for last four digits in phone number. My requirement is when user enter 3 numbers in textbox1 the focus should automatically go to textbox2. Problem... Since the above...
2
1452
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 press ENTER on a aspx, the "Menu" (means, the UserControl) disappears. Of course I can prevent pressing Enter - but the same problem still happens when I try to initialize all Textboxes using this code private void ClearTextBoxes(Control parent) ...
5
5060
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 change at execution(e,g: the TextBox with id & name"txtbox" in usercontrol "folder1" will have name "folder1:txtbox" and id "folder1_txtbox" during execution) Since I'll use the control in many place inside my project, it's not possible for me to...
1
2222
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 be used on a number of different ASPX pages (that's why I made it a ASCX). When clicking the image button, I run simple JavaScript to open another popup ASPX page that contains a calendar control and two dropdownboxes for the time (hours :...
5
3690
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> function CheckQuestion() { var checkBox = document.getElementById('SecurityStandard'); alert("checkBox.checked = " + checkBox.checked);
0
2492
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 to the webpage (typically to tell it that it has finished doing something). I started digging around and found out that I needed to implement a COM interface for the .NET user control, and pick up the events from that in Javascript on the...
0
1873
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 contains a value, then I would open a pop-up window. I am showing the HyperLink control only sometimes and I set the NavigateUrl only in these cases. In order to implement the pop-up window I try to put the javascript function into the file .ascx...
0
1169
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 these controls I would like to add some javascript to the page loading my control. The problem is only - nothing happens. The code that loads my usercontrol from my ASPX-page is: tdContent.Controls.Add(Page.LoadControl(contentControl));
2
3740
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 usercontrol will fire this event upon certain action by the user. I tried to let the aspx page subscribe to this event via <script for="winObj1" event="DoEvent()" language="javascript"> window.alert("window control event happen!");
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5399
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.