Home All Groups Group Topic Archive Search About

newbie script question

Author
20 Jun 2006 2:11 PM
CGW
Why is it that sometimes I get an error that one of my embedded scripts in
the aspx page is not a member of the class, and at other times, there is no
problem at all referencing the function? For example, on a panel load, I
reference a function...

<asp:Panel ID="pnlIncrementalEntry" Runat="server" Visible="False"
OnLoad="Set_IncrementalFocus();">

It doesn't seem to matter where I put the function; in the panel, in the
header, etc. I still get the message...


Compiler Error Message: BC30456: 'Set_IncrementalFocus' is not a member of
'ASP.WeekHours_aspx'.

The function, set between script tags, couldn't be simpler...

function Set_IncrementalFocus()
{
    document.frmLogin.txtIncrementalHours.focus();
}

Any ideas?
--
Thanks,

CGW

Author
20 Jun 2006 4:41 PM
Travers Naran
CGW wrote:
> Why is it that sometimes I get an error that one of my embedded scripts in
> the aspx page is not a member of the class, and at other times, there is no
> problem at all referencing the function? For example, on a panel load, I
> reference a function...
>
> <asp:Panel ID="pnlIncrementalEntry" Runat="server" Visible="False"
> OnLoad="Set_IncrementalFocus();">

This ASP tag does not work the way you think it does.

> Compiler Error Message: BC30456: 'Set_IncrementalFocus' is not a member of
> 'ASP.WeekHours_aspx'.
>
> The function, set between script tags, couldn't be simpler...
>
> function Set_IncrementalFocus()
> {
>     document.frmLogin.txtIncrementalHours.focus();
> }

You're using Javascript.  When you set OnLoad for an ASP sever control,
the OnLoad attribute maps to a VB function, _not_ a JavaScript
function.  So in your case, you can do one of two things:

1. Define Set_IncrementalFocus() as a VB function (which is not what
you want in this case)

2. In the Page_Load() VB sub, add the following:

pnlIncrementalEntry.AddAttribute("onClick",
"javascript:Set_IncrementalFocus()")
Author
20 Jun 2006 6:00 PM
CGW
Thanks! Great so far. Any suggestions if I'd like to pass focus to a textbox
inside a repeater?
--
Thanks,

CGW


Show quoteHide quote
"Travers Naran" wrote:

>
> CGW wrote:
> > Why is it that sometimes I get an error that one of my embedded scripts in
> > the aspx page is not a member of the class, and at other times, there is no
> > problem at all referencing the function? For example, on a panel load, I
> > reference a function...
> >
> > <asp:Panel ID="pnlIncrementalEntry" Runat="server" Visible="False"
> > OnLoad="Set_IncrementalFocus();">
>
> This ASP tag does not work the way you think it does.
>
> > Compiler Error Message: BC30456: 'Set_IncrementalFocus' is not a member of
> > 'ASP.WeekHours_aspx'.
> >
> > The function, set between script tags, couldn't be simpler...
> >
> > function Set_IncrementalFocus()
> > {
> >     document.frmLogin.txtIncrementalHours.focus();
> > }
>
> You're using Javascript.  When you set OnLoad for an ASP sever control,
> the OnLoad attribute maps to a VB function, _not_ a JavaScript
> function.  So in your case, you can do one of two things:
>
> 1. Define Set_IncrementalFocus() as a VB function (which is not what
> you want in this case)
>
> 2. In the Page_Load() VB sub, add the following:
>
> pnlIncrementalEntry.AddAttribute("onClick",
> "javascript:Set_IncrementalFocus()")
>
>