accessing asp .net function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mr. Roboto

    #1

    accessing asp .net function

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

    <script language="VB" runat="server">
    Sub Clear()
    txtMessage.Valu e = ""
    Calendar1.Selec tedDates.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?
  • Marina

    #2
    Re: accessing asp .net function

    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.


    "Mr. Roboto" <aymerb@yahoo.c om> wrote in message
    news:01c001c36e 5a$3d0ba070$a40 1280a@phx.gbl.. .[color=blue]
    > for simplicity sake, i have this servers-side code:
    >
    > <script language="VB" runat="server">
    > Sub Clear()
    > txtMessage.Valu e = ""
    > Calendar1.Selec tedDates.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?[/color]


    Comment

    • Kumar Gaurav Khanna [.NET MVP]

      #3
      Re: accessing asp .net function

      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.

      --

      Regards,
      Gaurav Khanna
      ----------------------------------------------------------------------------
      ----------------
      Microsoft MVP - .NET, MCSE Windows 2000/NT4, MCP+I
      WinToolZone - Spelunking Microsoft Technologies


      "Mr. Roboto" <aymerb@yahoo.c om> wrote in message
      news:01c001c36e 5a$3d0ba070$a40 1280a@phx.gbl.. .[color=blue]
      > for simplicity sake, i have this servers-side code:
      >
      > <script language="VB" runat="server">
      > Sub Clear()
      > txtMessage.Valu e = ""
      > Calendar1.Selec tedDates.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?[/color]


      Comment

      Working...