accessing asp .net function

  • Thread starter Thread starter Mr. Roboto
  • Start date Start date
M

Mr. Roboto

for simplicity sake, i have this servers-side code:

<script language="VB" runat="server">
Sub Clear()
txtMessage.Value = ""
Calendar1.SelectedDates.Clear()
End Sub
</script>

i also have a regular html button tag.
<input type="button" value="OK" id="b1" onclick="Clear;">

is there a way i can access the server-side asp. net
function Clear() by clicking the button?
 
You need a runat="server" on that button, so it does a postback to the
server to do the clear. Also, I think you need to remove the ';' after the
Clear.

Right now it is trying to do this on the client - and you can't access
server side functions from the client.
 
Hi!

No, thats not possible since server side code can be accessed "only" by
server side code. Click event at the client side cannot do so, and will need
to simulate a postback that will transfer control to the server and the
server code can then access the method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top