473,406 Members | 2,371 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,406 software developers and data experts.

Q: Please tell me why this is not working.

Hi!

Enclosed code gives me a compiler error with the text

"Argument '1': cannot convert from 'System.Web.UI.ControlCollection' to
'System.Web.UI.Control'" and also

"The best overloaded method match for
'ArchitectDev.custdetail.AssignJavaScript(System.W eb.UI.Control)' has some
invalid arguments"

<--- CODE START --->
private void AssignJavaScript(System.Web.UI.Control ctrl)
{
foreach(System.Web.UI.Control c in ctrl.Controls)
{
if(c is TextBox)
{
((TextBox)c).Attributes.Add("OnChange", "DoChange");
}
AssignJavaScript(c);
}
}
private void Page_Prerender(object sender, System.EventArgs e)
{
AssignJavaScript(this.Controls);
}
<---CODE END -->

Just cant understand why, its the this.Controls it doesn't like...

How can i add the Page_Prerender to the PreRender event?
Do i have to do it manually or can i select the function in a property
editor?

Should i set this in Page_Load?

Regards
Martin Arvidsson

Nov 18 '05 #1
1 1414
this.Controls a ControlCollection, simply pass "this" since in your
AssignJavaScript function you are looking through the controlcollection of
the control you passed in.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Visual Systems AB (Martin Arvidsson)" <ma**************@vsab.net> wrote in
message news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi!

Enclosed code gives me a compiler error with the text

"Argument '1': cannot convert from 'System.Web.UI.ControlCollection' to
'System.Web.UI.Control'" and also

"The best overloaded method match for
'ArchitectDev.custdetail.AssignJavaScript(System.W eb.UI.Control)' has some
invalid arguments"

<--- CODE START --->
private void AssignJavaScript(System.Web.UI.Control ctrl)
{
foreach(System.Web.UI.Control c in ctrl.Controls)
{
if(c is TextBox)
{
((TextBox)c).Attributes.Add("OnChange", "DoChange");
}
AssignJavaScript(c);
}
}
private void Page_Prerender(object sender, System.EventArgs e)
{
AssignJavaScript(this.Controls);
}
<---CODE END -->

Just cant understand why, its the this.Controls it doesn't like...

How can i add the Page_Prerender to the PreRender event?
Do i have to do it manually or can i select the function in a property
editor?

Should i set this in Page_Load?

Regards
Martin Arvidsson

Nov 18 '05 #2

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

Similar topics

53
by: Bill | last post by:
Hello Programmers, I am looking for either Java Script (OR HTML etc) to DEFEAT Pop-up Stoppers e.g It will bring up a window that will LOOK like a Pop-up FEEL like a Pop-up Allow a name and...
8
by: Cyberdog | last post by:
HI, I am learning javascript, and at the moment I am working on truth tables. Can someone please tell me, is "NOT A AND B" the same as "NOT A AND NOT B". Thanks
4
by: anatushi | last post by:
Hi, im looking for help on how to add a text fader to my website, usually i'm working with css but in this case i need to add java script to make it work, that wasn't the problem but somehow it...
18
by: free2cric | last post by:
Hi, I attanded an interview on C++ Question asked were and my answers to them.. 1. In a CPP program what does memory leak occure? -- i said.. In a constructor , the pointer variables were...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
2
by: shapper | last post by:
Hello, I created a XSL file to convert a XML file to another XML. I am running this in Asp.Net but this is not working. ----- ORIGINAL XML ----- <?xml version="1.0" encoding="utf-8" ?>...
0
by: 2Barter.net | last post by:
" Given BACK what was freely GIVEN " More options 2 messages - Expand all 2Barter.net View profile More options Dec 12, 9:48 pm Blessing Are Country
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
112
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
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...

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.