Results 1 to 7 of 7

Thread: asp button - problem calling server function

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    asp button - problem calling server function

    Hi All,

    In my asp page I have:

    Code:
    <asp:Button ID="Button1" runat="server" Text="Button"  OnClientClick="checkFileExtension(MainContent_FileUpload1)" OnClick="Button1_Click" />
    when I click the button my onClientClick gets called correctly this is a javascript function. My Button1_click event never gets called. on my aspx.cs page it is declared:

    Code:
    public void Button1_Click(object sender, EventArgs e)
    I temporarily removed the onCLientClick event to see if that was interfering with this event, but it still never got called.

  2. #2
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: asp button - problem calling server function

    Make sure that function checkFileExtension is returning true or false depend upon ur validation? also it will be helpful if you can post the html mark up code
    __________________
    Rate the posts that helped you

  3. #3
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: asp button - problem calling server function

    I will laugh my ### off if this works.
    Go to developer view, drag a button and then double click on it so it automatically creates the event for click.
    Then try your code.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  4. #4
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: asp button - problem calling server function

    hello,
    Code:
    checkFileExtension
    as riteshjain1982 check your javascript function, if it return false then your server side event will not be called
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Re: asp button - problem calling server function

    in my Javascript function I already had return true and return false down their respective paths.

    I tried Sapator's suggestion and it did indeed cause my server side event to trigger, however, this triggers regardless of the value returned by my clientside function i.e. return true or false serverside still triggers.

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: asp button - problem calling server function

    Quote Originally Posted by Bill Crawley View Post
    I tried Sapator's suggestion and it did indeed cause my server side event to trigger
    Gotta love Microsoft!
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Re: asp button - problem calling server function

    when the client function returns false, I do not want the server fuhnction to trigger, but now it does regardless

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width