473,666 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Refering to <asp:> webcontrols

Hey,

Question, how can i create client-side javascript that refers to a asp.net
webcontrol. For example set the focus of a textbox lik this.

<asp: TextBox ID="Textbox1" />

(client side)
<script javascript>
Textbox1.focus( );
</script>

this wont't work, couse the webcontrol textbox1 has a diferent ID in the
actualy create HTML output. How can i solve this problem..

Thanks.

Henk

Jul 29 '06 #1
3 1337
henk wrote:
Hey,

Question, how can i create client-side javascript that refers to a
asp.net webcontrol. For example set the focus of a textbox lik this.

<asp: TextBox ID="Textbox1" />

(client side)
<script javascript>
Textbox1.focus( );
</script>

this wont't work, couse the webcontrol textbox1 has a diferent ID in the
actualy create HTML output. How can i solve this problem..

Thanks.

Henk
You can generate the javascript server side:

"<script type='text/javascript'>" + Textbox1.Client ID +
".focus();</script>";
Jul 29 '06 #2
Try this one:

document.getEle mentById("<%=Te xtBox1.ClientID %>").focus();
"henk" <he**********@v ersatel.nlwrote in message news:7d******** *************** ***@news.versat el.net...
Hey,

Question, how can i create client-side javascript that refers to a asp.net
webcontrol. For example set the focus of a textbox lik this.

<asp: TextBox ID="Textbox1" />

(client side)
<script javascript>
Textbox1.focus( );
</script>

this wont't work, couse the webcontrol textbox1 has a diferent ID in the
actualy create HTML output. How can i solve this problem..

Thanks.

Henk
Jul 29 '06 #3
What I have done is insert some Javascript to set the value for the ID of
the control. I start with this static Javascript.

var controlId;

function setControlId(id )
{
controlId = id;
}

Then I use Page.ClientScri pt.RegisterClie ntScriptBlock to add this code...

string script = "setControlId(' " + textbox1.Client Id + "');";

You can then have the client script wrapped automatically with the script
tags when it is registered. Then you just use the value for the controlId
in the rest of your Javascript.

Brennan Stehling
http://brennan.offwhite.net/blog/

"henk" <he**********@v ersatel.nlwrote in message
news:7d******** *************** ***@news.versat el.net...
Hey,

Question, how can i create client-side javascript that refers to a asp.net
webcontrol. For example set the focus of a textbox lik this.

<asp: TextBox ID="Textbox1" />

(client side)
<script javascript>
Textbox1.focus( );
</script>

this wont't work, couse the webcontrol textbox1 has a diferent ID in the
actualy create HTML output. How can i solve this problem..

Thanks.

Henk

Sep 11 '06 #4

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

Similar topics

5
3744
by: Fresh Air Rider | last post by:
Hello Could anyone please explain how I can pass more than one arguement/parameter value to a function using <asp:linkbutton> or is this a major shortfall of the language ? Consider the following code fragments in which I want to list through all files on a directory with a link to download each file by passing a filename and whether or not to force the download dialog box to appear.
0
1625
by: Drew Pawlik | last post by:
Hey guys, I'm having a problem and need some help. I have an <asp:table ...> in my web page, and this table has 2 rows, the first being a header row, and the second row containing an <asp:button> to add rows to the table. Well, when I add the first row it shows up, but if I try to add any more rows, the one I added + the rest of them all disappear. I tried saving the table to a Session variable, but that didn't work. I'm not really sure...
0
1251
by: Martin Jacobsson | last post by:
Hi! I have just installed VS.NET 2003, I have problem with intelisense in <asp:>-tags in aspx-files. I prevoiusly ran VS.NET and had no problems with this. Is it some property on the project or in the environment that I am not aware of? br Martin Jacobsson
1
1646
by: s8chem | last post by:
I'm working with an XSL document that renders ASP.NET Server Controls. In order to do this, I have to declare an "asp" namespace within the XSL document. This namespace is the same as when you see a line like this: <asp:label> in an ASPX page. My question is where is this namespace declared? In an XSL document you see a line such as: xmlns:xsl="http://www.w3.org/1999/XSL/Transform" which points to a URI that resolves the namespace.
0
1329
by: Bryan Donaldson | last post by:
I have a table on my web form, declared like this: <asp:table id="tblOverrides" runat="server" enableviewstate=true" cssclass="clsTable"> <asp:tablerow cssclass="clsTblHeader"> <asp:tablecell Text="label" id="hdrLabel"></asp:tablecell"> <asp:tablecell Text="ddl" id="hdrDDL"></asp:tablecell"> </asp:tablerow> </asp:table> -----------------------------------------------------------------------
5
2099
by: Ken Dopierala Jr. | last post by:
Hi, This is just a query about what people use most. Up until today I've been using <asp:Table> tags to build my tables. We just outsourced our HTML design to a local guy and when I got it back today I was working with the html <table> <tr> <td> etc. What a difference that makes, server controls are even automatically declared in the code behind when using the generic HTML controls. I think I'm going to switch over to using them...
4
2542
by: Jim Bancroft | last post by:
Hi everyone, I've been working with ASP.Net for about a month, and in all the samples I've seen the authors know ahead of time how many DropDownLists or Labels they're going to need. My problem is that I don't always know at design time how many (for instance) DropDownLists I'll need. As an example, one of my old asp pages queries a table and loops through the resulting recordset, adding one DropDownList per entry and populating it...
5
2218
by: Alex Maghen | last post by:
I frequently find myself wanting to insert some basic client-side JavaScript functions in the page of an ASPX of mine. But I find it so frustrating that I have to actually contruct my JavaScript in C# on the server-side and render it to the client because I can't use the IDs of my controls as they are written in the HTML page itself. Rather, I have to use Control.ClientID to get that ID that I can use in the client-side JS. So my...
0
2934
by: reema | last post by:
EJB Interview Questions http://interviewdoor.com/technical/EJB-Interview-Questions.htm CSS Interview Questions http://interviewdoor.com/technical/CSS-Interview-Questions.htm C Interview Questions http://interviewdoor.com/technical/C-Interview-Questions.htm C# Interview Questions http://interviewdoor.com/technical/C-sharp-Interview-Questions.htm C++ Interview Questions http://interviewdoor.com/technical/C++-Interview-Questions.htm
0
8866
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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...
0
8639
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
7385
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
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
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.