Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with calling sub from a sub..?

Status
Not open for further replies.

golyg

Programmer
Jul 22, 2002
319
US

Here is my problem:
I have a textbox, for a password, and I want the user to be able to hit enter and it would act just like clicking on the "enter" button.
When I do this I receive the following error:
"Type mismatch: 'btnLogin_onclick'"

When I comment out that line and leave the msgbox, all works fine....Any ideas would be gratefull,
Thanks...
Code below
<code>

<INPUT type=&quot;password&quot; id=txtPass name=txtPass size=&quot;12&quot; onkeydown=&quot;buttonPress();&quot;>

<script LANGUAGE=&quot;vbscript&quot;>
sub buttonPress()
dim i
i = window.event.keyCode
if i = 13 then
call btnLogin_onclick
'msgbox &quot;TESTING&quot;
end if
End sub
</script>



<script ID=&quot;serverEventHandlersVBS&quot; LANGUAGE=&quot;vbscript&quot; RUNAT=&quot;Server&quot;>

Sub btnLogin_onclick()

rsAccess.open

If rsAccess.EOF and rsAccess.BOF Then
noAuth = &quot;failed&quot;
Else
Session(&quot;Auth&quot;) = rsAccess.fields.getValue(&quot;Auth&quot;)
Session(&quot;User&quot;) = rsAccess.fields.getValue(&quot;Who&quot;)
End If

If rsCases.isOpen() then
rsCases.close
rsCases.open
end if

End Sub
</code>

 
Add a </script> tag at the end of the last btnLogin_onclick() sub
 
After the btnLogin_onclick() there are a couple of more subs and finally there is a </script> tag...
sorry for the typo in the original.. but that is not causing my problem.

thanks
 
Hello golyg,

[1] Make sure the rs is within scope.
[2] Instead of runat=server---in particular if you somewhere else use <% %> tag, use the <% %> tag uniformly. There could very well be a priority problem for the compiler evaluating the server-side script according to this attribute/container. So, use the rendering like:
Code:
<script ID=&quot;serverEventHandlersVBS&quot; LANGUAGE=&quot;vbscript&quot;>

Sub btnLogin_onclick()
<%
  rsAccess.open
    
  If rsAccess.EOF and rsAccess.BOF Then
     noAuth = &quot;failed&quot;
  Else
     Session(&quot;Auth&quot;) = rsAccess.fields.getValue(&quot;Auth&quot;)
     Session(&quot;User&quot;) = rsAccess.fields.getValue(&quot;Who&quot;)
  End If
    
  If rsCases.isOpen() then
     rsCases.close
     rsCases.open
  end if
%>
End Sub
regards - tsuji
 
I appreciate everyones help...
OK, the sub buttonPress() is being called by the client-side, the password textbox.
Can I call a server side sub from a client-side sub?

If I remove the runat=&quot;server&quot; from the script declaration, then the enter button, &quot;btnlogin&quot; becomes non-functional...
and I receive an error stating: &quot;Object required: 'rsAccess'

The btnLogin sub works fine if I leave it alone except the user wants the ability to hit the Enter key to login rather tabbing down to the actual Enter button...

this is driving me crazy...


thanks again,
 
golyg,

>Can I call a server side sub from a client-side sub?

I don't think so...

regards - tsuji
 
So I guess thats the holdup with this issue.....?

I am trying to call a server side sub from a client side sub...
Is there anyway for me to implement this? I mean, you see it all over the place...The ability to hit enter on a password textbox..


thanks for all your help,
 
golyg,

Apart from you getting good info from members frequenting this forum, I would suggest you post a clean version of your problem in the asp forum. There are fellows really good at this as well.

- tsuji
 
Your right tsuji..sorry for this lingering problem posting...

Thanks for everyones tips,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top