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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Methods

Status
Not open for further replies.

yu217171

Programmer
Joined
Aug 2, 2002
Messages
203
Location
CA
Hi everyone,

How can I invoke methods in my codebehind from my .ASPX web form? My method is declared as

public void myFunc()
{
Response.Write ("Hello World");
}

In my .ASPX, I've tried

<script runat=&quot;server&quot; language=&quot;C#&quot;>
myFunc();
</script>

as well as

<% myFun() %>

and both aren't working. Any ideas? Thanks in advance.
 
not 100% sure, but I'd think you'd have to tie it to an event somehow. like the onclick of a button, etc.
 
gagz is right you must link the method call to an event:

eg

Sub btnSubmit_Click(sender as Object, e as EventArgs)
myFun()
End Sub

onPageLoad is a good one to test your method

hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top