Hi all,
In my code-behind, I validate some controls and if a particular control has
a problem, I not only send an alert down to the client via
Page.RegisterStartupScript but I'd like to set the focus of the control. now
the control in question is embedded into a user control which is, in turn,
embedded into a user control which, in turn, is embedded onto a web form.
The Javascript does not work if I when I refernce the control with it's ID.
I checked the client source and saw it was renamed to
'_ctl2_UCIngDetail_lstUnits2'. Now when I changed the Javascript to
'document.frmMain._ctl2_UCIngDetail_lstUnits2.focu s();', this worked. but
isn't this going to break if controls are added to the usercontrol?
What is the correct way to solve this dilemma?
Regards
John. 2 3625
You will need to use the "ClientID" property of the control to reference it
properly.
"John" <a@b.com> wrote in message
news:#U**************@TK2MSFTNGP10.phx.gbl... Hi all,
In my code-behind, I validate some controls and if a particular control
has a problem, I not only send an alert down to the client via Page.RegisterStartupScript but I'd like to set the focus of the control.
now the control in question is embedded into a user control which is, in turn, embedded into a user control which, in turn, is embedded onto a web form.
The Javascript does not work if I when I refernce the control with it's
ID. I checked the client source and saw it was renamed to '_ctl2_UCIngDetail_lstUnits2'. Now when I changed the Javascript to 'document.frmMain._ctl2_UCIngDetail_lstUnits2.focu s();', this worked. but isn't this going to break if controls are added to the usercontrol?
What is the correct way to solve this dilemma?
Regards John.
js ="<script ...>" & txtBox.ClientID & ".focus();</scirpt>"
"John" <a@b.com> wrote in message
news:#U**************@TK2MSFTNGP10.phx.gbl... Hi all,
In my code-behind, I validate some controls and if a particular control
has a problem, I not only send an alert down to the client via Page.RegisterStartupScript but I'd like to set the focus of the control.
now the control in question is embedded into a user control which is, in turn, embedded into a user control which, in turn, is embedded onto a web form.
The Javascript does not work if I when I refernce the control with it's
ID. I checked the client source and saw it was renamed to '_ctl2_UCIngDetail_lstUnits2'. Now when I changed the Javascript to 'document.frmMain._ctl2_UCIngDetail_lstUnits2.focu s();', this worked. but isn't this going to break if controls are added to the usercontrol?
What is the correct way to solve this dilemma?
Regards John.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Data Guy |
last post by:
In my approach to validation for widgets, i write javascript functions.
At the end of the document, inside the form, i invoke the function as
<FORM NAME="testit">
<INPUT TYPE="TEXT" VALUE="2"...
|
by: Dune |
last post by:
Saw a post a about hiding a panel using javascript a while
back and that got me curious and i tried it out.
I have a Panel control with id equal to PanelId and it is
nested inside a form tag...
|
by: Martin |
last post by:
Hello Group
I'm having a bit of trouble figuring this out. I'm grateful for any
hints.
Let's assume I'm have a webapplication with two .aspx pages, Page A
and Page B.
Page A consists of a...
|
by: Lyners |
last post by:
I have a table within a cell of a datagrid. I am doing updates without
postback to the server using Javascript. I have everything working, except
referencing a table within the datagrid cell.
...
|
by: gary |
last post by:
Hi,
I am trying to reference an anchor in a user control with a url. This
worked in 1.1 but no longer works in 2.0.
The ascx control is located in a "/include" folder
If you have a...
|
by: WB |
last post by:
Hi,
I would like to do something like this page:
http://www.stocklayouts.com/Products/Postcard/Postcard-Template-Design-Library.aspx?kwid=38
Notice when you mouse-over any of the icons under...
|
by: cmd |
last post by:
I have code in the OnExit event of a control on a subform. The code
works properly in this instance. If, however, I put the same code in
the OnExit event of a control on a Tab Control of a main...
|
by: DanG |
last post by:
Hi
I used to have an ImageButton in my datagrid, and referenced the
control in the javascript with:
var fld = document.getElementById('datagrid__ctl2_btnEdit');
alert(fld); //returns "" >Good...
|
by: HockeyFan |
last post by:
Yesterday, I posted a question dealing with an issue of trying to
reference (from javascript on the client side) an item within a
Repeater. My code was hard-coded to use the actual ClientId, but...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
| |