473,408 Members | 1,775 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,408 software developers and data experts.

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 1329
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.ClientID +
".focus();</script>";
Jul 29 '06 #2
Try this one:

document.getElementById("<%=TextBox1.ClientID%>"). focus();
"henk" <he**********@versatel.nlwrote in message news:7d**************************@news.versatel.ne t...
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.ClientScript.RegisterClientScriptBlock to add this code...

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

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**********@versatel.nlwrote in message
news:7d**************************@news.versatel.ne t...
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
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...
0
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>...
0
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...
1
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...
0
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 ...
5
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...
4
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...
5
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...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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
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...
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...

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.