F
Faizan Ahmed
Hello all,
I have an asp.net textbox (named txtHidden) and an HtmlButton(named
btnAction). I wanted to write a javascript function which will get called
when the btnAction is clicked. The function is as follows
function HideText()
{
document.all.item("txtHidden").style.visibility = "hidden";
}
This function works fine when i run it in an asp.net page.
The problem is that it doesn't work inside a user control. i.e. lets say i
place the two controls and the javascript to work on them, in a user
control(say MyUC), then the statement document.all.item("txtHidden") does
not return anything.
After a bit of effort i've been able to identify that when a user control is
placed on a page, asp.net, while rendering the page appends all the child
control of a user control with the client id of the user control to avoid
naming conflicts. So after the page is rendered the id of "txtHidden" is
changed to "myUC1_txtHidden".
Since at the design time of UC we dont know the ClientID of the user
controls, therefore this makes it impossble to write javascripts in a user
control, which is exactly what i want to do.
Any help will be highly appreciated.
Regards
Faizan Ahmed
I have an asp.net textbox (named txtHidden) and an HtmlButton(named
btnAction). I wanted to write a javascript function which will get called
when the btnAction is clicked. The function is as follows
function HideText()
{
document.all.item("txtHidden").style.visibility = "hidden";
}
This function works fine when i run it in an asp.net page.
The problem is that it doesn't work inside a user control. i.e. lets say i
place the two controls and the javascript to work on them, in a user
control(say MyUC), then the statement document.all.item("txtHidden") does
not return anything.
After a bit of effort i've been able to identify that when a user control is
placed on a page, asp.net, while rendering the page appends all the child
control of a user control with the client id of the user control to avoid
naming conflicts. So after the page is rendered the id of "txtHidden" is
changed to "myUC1_txtHidden".
Since at the design time of UC we dont know the ClientID of the user
controls, therefore this makes it impossble to write javascripts in a user
control, which is exactly what i want to do.
Any help will be highly appreciated.
Regards
Faizan Ahmed