Client Side Javascript and Dynamic Client Ids

I have a gridview that has an edit row.  When I click on edit... It pops up a inline window with modal functionality in the css...

I want to fire off a webservice to bring back data to populate the input fields on the form I created...

one catch I created a tab container with panels to separate out the keyed in information...

So, I found that the .net is doing this to the inputs...

 <input name="ctl00$cphMainBody$tcEmployeeDetails$TabPanel1$txtFirstName" type="text" maxlength="25" id="ctl00_cphMainBody_tcEmployeeDetails_TabPanel1_txtFirstName" style="width:130px;" />

Appened the prefix to the name I gave it..

Well I can't reference it the normal way of getElementById("txtFirstName") becuase they changed it...

And I don't want to hard code the ID in...

using this.ClientID won't work because they are clicking a button in a grid and not directly accessing the textbox element...

A littl fustrating because there was no reason why they needed to rename the textbox controls it is not like a grid who will have multiple rows with the same controls for each row

Anywqay, how can I set or find out what the ids are?

Many thanks,



11/4/2007 7:06:48 PM 9760 articles. 0 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 18

You don't suppose to know the client id of the text-box, however you  do know the client id of the button.

(Access it by the <event element>  From the ID you can extract the prefix and then - just add the server ID of the text-box

control as it's suffix, then you have the id of your text-box.

11/4/2007 8:35:47 PM

Hi thanks for replying,

I don't know if I am understanding you correctly but I will give you the source that is produced..

the button code which is in a gridview is

<input type="image" name="ctl00$cphMainBody$gvEmployeeList$ctl13$ibEdit" id="ctl00_cphMainBody_gvEmployeeList_ctl13_ibEdit" src="images/grid_edit.gif" onclick="getEmployeeRecord();return false;" style="border-width:0px;" />

the text box code which is in a tabpanel is

<input name="ctl00$cphMainBody$tcEmployeeDetails$TabPanel1$txtFirstName" type="text" maxlength="25" id="ctl00_cphMainBody_tcEmployeeDetails_TabPanel1_txtFirstName" style="width:130px;" />

 looking at your suggestion, I don't feel it will work because they do not have the same control naming path... but maybe I am miss understanding you...

 thanks for your help :)

Angela Law

11/4/2007 8:40:41 PM

 OK, you are right. My suggestion won't work because both control not under
the same naming path. However, you can give the getEmployeeRecord function a parameter
of the textbox client id by adding the onclick attribute programaticly  on your code behind (in your data biding event handler)

Because you invoke an asynchronous web method you may want to keep the client id in a temporary global var
or using the server as an echo (sending the parameter and receiving it within the result), so your client event handler
will know which text-box to populate.

For example you can use a cascading drop-down from Ajax toolkit and see how it handles the populating things.

11/5/2007 5:05:01 AM

Thanks I will decided to keep it in a global variable...

 I appreciate your time that you gave to me!

 Yours in deepest gratitude,

Angela law

11/6/2007 12:16:45 PM

Similar Artilces:

How to write data to a file in client side using javascript or someother client side scripting language.
Hi, I would like to know how to write a data to a client side file using javascript or someother client side scripting language. The file type expected is ini file. txt file would also be appreciable. Thanks in advance.   If the site is a trusted and you are running IE then you could try The Old Sewing FactoryThat twitter nonsense. You can write to the server, but not to the client's machine.  Being able to do so would be a huge security breach.When you ask a question, remember to click "mark as answered"...

populate javascript client side with ajax.
I have the following:function year_onchange(sender, e) {var y = ddlYear.options[ddlYear.selectedIndex].text; var m = ddlMonth.value;   // Add an Option object to Drop Down/List Boxvar totalDaysInMonth = daysInMonth(m, y);var element = document.getElementById("ddlDay"); alert (totalDaysInMonth);for (var i = 0; i < totalDaysInMonth; i++) {element.options[element.length] = new Option(i, i); } } It does not populate the dropdownlist in the below code.<asp:Label ID="lblDOB" runat="server">Date of Birth: </asp:Label> &nbsp; &l...

.Net varible into client side JavaScript
I'm need to get a variable from my web app and place its value in a JavaScript. I tried doing this with a Label but I get the HTML included. I don't think I can use the <%# %> from classic ASP? Anyone have any ideas on how they would approach this problem? tbone_stl wrote:Anyone have any ideas on how they would approach this problem? Hi, and welcome to the ASP.NET forums. It's possible to pass a variable to a javascript function. I created a small coding snippet: <%@ Page Language="C#" %>   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http...

Client vs. Server Side AJAX.Net
I am curious to know what the advantages and disadvantages are to using the client side declarative style AJAX controls vs. the server side.  I can't seem to think of too many reasons why I would go to the client side libraries when I can use all the power of ASP.NET (debugging, compiling, controls) and just wrap them in a UpdatePanel.   It also seems kind of counter productive to use the client side libraries because they don't utilize all the cool new developments of ASP.NET.  Am  I missing something?  Do the client AJAX libraries give you m...

dynamic add a few textBox by Javascript (client side)
VS.NET 2003, Framework 1.0 , (VB) , SQL 2005 i'm having a problem is ...i 'm using js to add a few textbox dynamically when i clicked  AddNewRow()so when i wanna use (server side) VB codebehind to get the txtbox look like canot get it.... bcoz the txtbox is like not defined in WEB page.    HOw ?????? helps thx Hello, I am afraid you could not access the TextBox from Server side when you create the TextBox from client side. The Server knows nothing about the TextBox Control. My suggestion is if you really want to avoid postback when you ad...

Good articles on client-side callbacks in .net AJAX?
Not sure where to put this so sorry if its in the wrong place.  I have just watched the video - "Make Client-Side Network Callbacks with ASP.NET AJAX?" ( ). Which is very helpful but I would like to know more about doing this. Anyone know of any good articles/sites with information on client-side callbacks in .NET AJAX? I can find plenty of articles on other implementations of AJAX but none for the AJAX. Cheers for any help. Hi,and welcome to the ASP.NET forums.You're going to find a lot of interesting artic...

Using AJAX and client side scripting with .NET objects?
I'm wanting to use client-side scripting and AJAX with some drop down boxes.  I can't seem to do this with server-side .NET objects... changing the runat tag doesn't do anything either.  How can I expose .NET server objects so that they are affected by java script and AJAX? Depends on what, exactly, you're trying to do with them.  If you just need access to the html properties (e.g. selectedValue), then you simply grab them as if they were their html equivilants (select element) in javascript.  If you want to pass custom properties back and forth (or any .Net property ...

Dynamically load page using client side javascript
Hi, I have a fairly large page that i need to load. I've written it completely from the ground up using ajax. What i'd like to know, using a control such as the UpdatePanel, can i design my page, let it load and from javascript that runs on the body load event, initialize all the update panels to start collecting their data? Thus allowing my user to start working on the system while the data is being collected in the background? There are various "pages" (i.e. div's that get shown/hidden) and each one is inside an UpdatePanel. Thanks Actually you do not need Ajax to do that, you can u...

How to use client-side script(javascript) in .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script>  objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ......  }    szUrl = &...

Adding nodes to a treeview dynamically from client-side javascript.
I have a treeview control on my page. I can access it through javascript using the following statement:       document.forms[0].UltraWebTree1.But how can i add nodes to this treeview dynamically from client side javascript?...

Perform JavaScript Client Side Confirmation from a VB.NET DataGrid
Hi, I when I delete an item from the database through a Datagrid I want to get a messagebox popingup to give me the choise to Confirm case I clicked the wrong item....the way it works now it just deletes it....can any one help me with an Example I have no Idea how to do this...I found an article in C# but it didnt help me at all. here is my source code <asp:DataGrid ID="dgCustList" Runat="server" AutoGenerateColumns="False" DataKeyField="id" AlternatingItemStyle-BackColor="#F6F6F6" HeaderStyle-BackColor="#C4B58E" CellSpacing="0" CellPadding="2" GridLines="Vertical" Width="100%"...

How do I turn Ajax On/Off in client side javaScript
Hi,I am very impressed with the AJAX toolkit and like the way it complements ASP.Net.I am a first time user of this code and hoped you could help me with a problem.I am writing an application which makes use of the CascadingDropDown Extension.The user wants the option of being able to change the values in any 1 of 6DropDownLists and upon which the application goes and retrievesdata from the database.However they also want the option of being able to turn off Ajax(I guess with a checkbox), select values from the dropdownlistsand then click a submit button to retrieve the values fromthe databa...

.net validators + client-side javascript validation, EnableEventValidation=false
Scenario: 1. I have a DropDownList, with 2 listitems in the .aspx. appenddatabound=true and it is tied to a datasource (via datasourceid), autopostback=false, onchange=checkIfAddNew(this) [this is the client side onchange event]The second option on this dropdown is "Add New", and the checkIfAddNew function pops up a new window and when it returns, it adds the newly created option to the dropdown. In order for this to happen without getting mad, EnableEventValidation has to be set to false in the Page directive. In addition to this dropdownlist, there is a RequiredFieldValidator...

List of client side function of extenders and controls for client side
Hello All,I am using AJAX control toolkit for my current project. Now I need to find out what client side functions I can call on an extender. Lets say I am using a PopControlExtender. Now I want to show the popup from a JS funtions.If I can do a guess then it would be something like this$find('ppce').show();From where I can find what client side functions I can call on those extensders. This is really a frusterating thing. I learn about extenders only from Learn tutorials, no help here and there. Can anybody please tell me where are documentations about all the extenders in the tool...

Web resources about - Client Side Javascript and Dynamic Client Ids -

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

Lightbox (JavaScript) - Wikipedia, the free encyclopedia
On a Lightbox-enabled page, a user can click an image to have it magnified in a Lightbox window, which resizes itself according to the size of ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
about dmoz - help Top : Computers : Programming : Languages : JavaScript : Tools : Obfuscators Tools for obfuscation/compression JavaScript code. ...

Facebook File-Transfer App Pipe Relaunches, Now Works Via JavaScript, WebRTC
... allowed Facebook users to send and receive files up to 1 gigabit in size. A new version of Pipe debuted Monday, and the app now works via JavaScript ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

JavaScript SDK - Facebook-Entwickler
Overview The JavaScript SDK provides a rich set of client-side functionality for accessing Facebook...

Senior Front-End Developer (Javascript and AJAX)
Company: Sometrics Category: Software Development Location: Los Angeles, CA How to Apply: Description: We are looking for ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken .… ...

Resources last updated: 11/26/2015 6:15:52 PM