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

Repost: How to determine ID of object in custom web control

Sorry about the repost... but my original post had funky characters
that was causing it to get truncated.

I've got a rather simple custom web control that has an object delcared
as HtmlControls.HtmlInputHidden. I set the ID = 'PageNo' and the Name
= 'PageNo'. However, when I look at the page source in the browser,
the object's ID is "WebCtl3_PageNo" and the Name is "WebCtl3:PageNo".
I'm reference the object in javascript as
document.all['WebCtl3_PageNo'] but that seems lame. I get the feeling
that the ID will somehow magically change to "WebCtl2_PageNo" or
"WebCtl4_PageNo" without me realizing it. Is there a better way? I
need to reference it in javascript on the client side. Is there a way
to iterate through document.all and looke for "*PageNo"?

Mar 21 '06 #1
1 1200
Yea that Webcl2 naming could change depending on what controls you put in
your aspx page.
Your best bet is try reference your control's ClientID property and try to
inject that into your javascript via a method arg or a global javascript
variable.

There were sometimes where i couldnt pass the clientId into my javascript so
I had to resort to this kind of sillyness:
function FindControl(searchString)

{

var formElements = document.forms[0].elements;

for(var i=0;i<formElements.length;i++)

{

if(formElements[i].id.indexOf(searchString) > -1)

{

return formElements[i];

}

}

}

sorry about the formatting. Like i said try and use the ClientID.
"Jeffrey Frabutt" <je************@gmail.com> wrote in message
news:2006032111100075249-jeffreyfrabutt@gmailcom...
Sorry about the repost... but my original post had funky characters that
was causing it to get truncated.

I've got a rather simple custom web control that has an object delcared as
HtmlControls.HtmlInputHidden. I set the ID = 'PageNo' and the Name =
'PageNo'. However, when I look at the page source in the browser, the
object's ID is "WebCtl3_PageNo" and the Name is "WebCtl3:PageNo". I'm
reference the object in javascript as document.all['WebCtl3_PageNo'] but
that seems lame. I get the feeling that the ID will somehow magically
change to "WebCtl2_PageNo" or "WebCtl4_PageNo" without me realizing it.
Is there a better way? I need to reference it in javascript on the client
side. Is there a way to iterate through document.all and looke for
"*PageNo"?

Mar 21 '06 #2

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

Similar topics

6
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
0
by: m. pollack | last post by:
<I've reposted this as it was slipping away over the horizon Hi all, I've been writing an application that uses a class object (call it Element) that I need to expose to the user at runtime for...
14
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant...
2
by: Walter | last post by:
Each of the aspx pages in my application have a User Control called "WrapStart". In a page's Page_Load() method, I set various properties and/or call various methods of the WrapStart control...
5
by: Adrian Parker | last post by:
I've got the standard SqlCacheDependency working just fine , ie. I've defined (and encrypted) the connectionStrings section in the web.config, and I've also defined an an sqlCacheDependency in the...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
3
by: Beavis | last post by:
I hate to repost a message, but I am still at the same point where I was when I originally posted, and hopefully someone else will see this one... Ok, so I have gone off and documented the...
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:
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...
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
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:
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
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,...
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...

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.