Call a function through a Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dexterous22
    New Member
    • Jun 2007
    • 8

    Call a function through a Button

    Can anyone tell me how to call a function through a button in Page Language="C#" not vb ..
    Please help .. I really need this
    thanks
  • TRScheel
    Recognized Expert Contributor
    • Apr 2007
    • 638

    #2
    Originally posted by Dexterous22
    Can anyone tell me how to call a function through a button in Page Language="C#" not vb ..
    Please help .. I really need this
    thanks

    Attach the Button.OnClick event to the function in question

    Comment

    • Dexterous22
      New Member
      • Jun 2007
      • 8

      #3
      thanks but can you give an example ?
      my Function is : updatefun
      <input id="Button1" runat="server" type="button" onclick=updatef un()value="UPDA TE"/>

      isn't working .. i don't know how should the value be in ONCLICK
      please help

      Comment

      • TRScheel
        Recognized Expert Contributor
        • Apr 2007
        • 638

        #4
        Originally posted by Dexterous22
        thanks but can you give an example ?
        my Function is : updatefun
        <input id="Button1" runat="server" type="button" onclick=updatef un()value="UPDA TE"/>

        isn't working .. i don't know how should the value be in ONCLICK
        please help

        You need an asp control (I believe? I could be wrong) to call an c# function. That is going to call a javascript function. In addition, you are missing ' around the function name.

        An example asp control would be
        <asp:Button ... />

        Comment

        • chinu
          New Member
          • Jun 2007
          • 36

          #5
          Originally posted by TRScheel
          You need an asp control (I believe? I could be wrong) to call an c# function. That is going to call a javascript function. In addition, you are missing ' around the function name.

          An example asp control would be
          <asp:Button ... />
          try this
          <asp:Button ID="Button1" runat="server" Text="Button" OnClick="onUpda teFn" /></div>

          Comment

          • Dexterous22
            New Member
            • Jun 2007
            • 8

            #6
            thanx.. but it really doesn't work
            all i get is errors :S .. with .Net debugger :

            Parser Error Message: Content ('</div>
            </form>') does not match any properties within a 'System.Web.UI. WebControls.But ton', make sure it is well-formed.

            Source Error:


            Line 36:
            Line 37:
            Line 38: <asp:Button ID="Button1" runat="server" Text="Button" OnClick="onUpda teFn"></div>
            Line 39: </form>
            Line 40:

            ?? and ideas ?s

            Comment

            • TRScheel
              Recognized Expert Contributor
              • Apr 2007
              • 638

              #7
              Originally posted by Dexterous22
              thanx.. but it really doesn't work
              all i get is errors :S .. with .Net debugger :

              Parser Error Message: Content ('</div>
              </form>') does not match any properties within a 'System.Web.UI. WebControls.But ton', make sure it is well-formed.

              Source Error:


              Line 36:
              Line 37:
              Line 38: <asp:Button ID="Button1" runat="server" Text="Button" OnClick="onUpda teFn"></div>
              Line 39: </form>
              Line 40:

              ?? and ideas ?s
              You need to close the button. Change the > at the end to a />.

              Comment

              Working...