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

Trying to find ClientID of web form - Solution Found

After pouring over about a dozen sites that clearly dealt with ClientID
all by itself, I came to the realization that about 2/3+ of them were
doing it wrong. It is indeed impossible to grab the Client ID of a form
field from within a DataGrid like this: <%= FormFieldID.ClientID %>. At
least, not without extra work.

How did I do this? I created a new DataGrid from scratch, with a form
above it and a form inside of it. This was a page about 50 lines long -
so, very short - with no user dependencies except for the initial
loading of the DG with content from the DB.

While I was able to get the ClientID of the form that was outside of the
DG, I was unable to do so for any form fields inside of the DG using <%=
FormFieldID.ClientID %>. Doing so threw the error.

That got me to thinking. Which, after nearly two days of rest from the
subject, was a wee bit clearer than before Sunday.

I decided to call the form field directly. I first Dim'd a name as a
textbox, and then I called the right textbox by catching it when the DG
was being created. Since it was in the footer (the footer is an "add"
row) simply calling like this:
Dim add_Date as TextBox = e.Item.Cells(1).FindControl("add_Date")
was a bit difficult. Which row would be referenced? How would the script
know to look in the footer? Since the footer comes and goes (I don't
need it during an edit), looking for it would have to be conditional.

In order to catch the right row (the footer) while the DG is being
built, I added a feature to the DataGrid itself (onItemDataBound =
"dg_ItemDataBound") which calls the sub dg_ItemDataBound when the
DataGrid is being built.

From here, I created a Sub (Sub dg_itemDataBound()) in which I
contained my attempt to find the ClientID of the form field within the
footer:
If e.Item.ItemType = ListItemType.Footer And dg.ShowFooter = True then
Dim add_Date as TextBox = e.Item.Cells(1).FindControl("add_Date")
End If
From here it was pretty easy to set up a RegisterStartupScript (inside
the IF) that made use of add_Date.ClientID. Since I had already defined
add_Date as the form field called "add_Date" in the second cell of the
footer row, the usage of add_Date.ClientID no longer threw an error.

I also had to implement this within the dg_Edit() Sub, in a slightly
different fashion, but that's because I allow rows to be edited.

***

What is really strange is the sheer number of sites that claim that
using <%= FormFieldID.ClientID %> will actually work inside of a
DataGrid without further modification or code. It certainly didn't work
for me.

I would also like to apologize to the community at large for my hissy
fit on the weekend. It had been a very long week, this was just one of
many problems I was still trying to solve, and Juan's reply seemed to be
mocking me for my lack of progress. Normally I'm much more mild
mannered, but something in me must have snapped from all the stress.
That should not have happened.

Gomen dasai.

TIA
....Geshel
--
************************************************** ********************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
************************************************** ********************
Nov 21 '05 #1
0 1259

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

Similar topics

1
by: Maras | last post by:
Hello, as we know VB is not case sensivity. I have a following problem, I have to send to another server few parametrs by post or get method, one of them MUST be a "clientID", it's preety...
2
by: kw | last post by:
TextBox t=new TextBox(); Controls.Add(t); t.ID=t.ClientID; //reads: "_MyControl1__ctl16" And even in OnPreRender, I examine the Controls collection and verify that the ID of the TextBox is...
2
by: Neo Geshel | last post by:
I need to get the ClientID of a form field for some JavaScript. About 25+ web sites I visited recommend the following method for finding the client ID of a web form: Web Form -> <asp:TextBox...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
2
by: Neo Geshel | last post by:
After pouring over about a dozen sites that clearly dealt with ClientID all by itself, I came to the realization that about 2/3+ of them were doing it wrong. It is indeed impossible to grab the...
1
by: kpg | last post by:
Hi all, I am using the ajax.net slider control an I added a client side value changed handler like this: function pageLoad() { $find('My_SliderExtender').add_valueChanged(OnValueChange); } ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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...

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.