Messagebox linked to link button

Discussion in 'ASP .Net' started by tshad, Jan 31, 2005.

  1. tshad

    tshad Guest

    I was looking at Scott Mitchells article:
    http://aspnet.4guysfromrolla.com/articles/090402-1.2.aspx the tells how to
    call a messagebox from a button and can almost get it to work but ran into 2
    problems. You have to press the button twice to get it to work and I can't
    figure out how to get an answer (OK or Cancel) from it.

    Here is the onClick function:

    sub Resume_Click(sender as Object, e as eventArgs)
    btnResume.Attributes("onclick") = "javascript:return " & _
    "confirm('Are you sure you want to delete FAQ #?')"
    end sub

    The linkbutton is:

    Would you like to submit a <asp:LinkButton id="btnResume"
    Text="Resume" onClick="Resume_Click" runat="server"/>&nbsp;?

    What am I missing?

    Thanks,

    Tom
     
    tshad, Jan 31, 2005
    #1
    1. Advertising

  2. Take the code out of the Resume_Click event and put it in the Page_Load
    event.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "tshad" <> wrote in message
    news:...
    >I was looking at Scott Mitchells article:
    >http://aspnet.4guysfromrolla.com/articles/090402-1.2.aspx the tells how to
    >call a messagebox from a button and can almost get it to work but ran into
    >2 problems. You have to press the button twice to get it to work and I
    >can't figure out how to get an answer (OK or Cancel) from it.
    >
    > Here is the onClick function:
    >
    > sub Resume_Click(sender as Object, e as eventArgs)
    > btnResume.Attributes("onclick") = "javascript:return " & _
    > "confirm('Are you sure you want to delete FAQ #?')"
    > end sub
    >
    > The linkbutton is:
    >
    > Would you like to submit a <asp:LinkButton id="btnResume"
    > Text="Resume" onClick="Resume_Click" runat="server"/>&nbsp;?
    >
    > What am I missing?
    >
    > Thanks,
    >
    > Tom
    >
     
    Steve C. Orr [MVP, MCSD], Jan 31, 2005
    #2
    1. Advertising

  3. > I was looking at Scott Mitchells article:
    > http://aspnet.4guysfromrolla.com/articles/090402-1.2.aspx the tells
    > how to call a messagebox from a button and can almost get it to work
    > but ran into 2 problems. You have to press the button twice to get it
    > to work and I can't figure out how to get an answer (OK or Cancel)
    > from it.
    >
    > Here is the onClick function:
    >
    > sub Resume_Click(sender as Object, e as eventArgs)
    > btnResume.Attributes("onclick") = "javascript:return " & _
    > "confirm('Are you sure you want to delete FAQ #?')"
    > end sub
    > The linkbutton is:
    >
    > Would you like to submit a <asp:LinkButton id="btnResume"
    > Text="Resume" onClick="Resume_Click" runat="server"/>&nbsp;?
    >
    > What am I missing?
    >
    > Thanks,
    >
    > Tom


    What you want to do is set the onclick attribute in the load or pre render.
    Then handle the click action in the Resume_Click method (ie, in this case,
    looks like you want to delete a faq entry, do it there).
     
    Ryan Trudelle-Schwarz, Jan 31, 2005
    #3
  4. tshad

    tshad Guest

    "Ryan Trudelle-Schwarz" <> wrote in message
    news:...
    >> I was looking at Scott Mitchells article:
    >> http://aspnet.4guysfromrolla.com/articles/090402-1.2.aspx the tells
    >> how to call a messagebox from a button and can almost get it to work
    >> but ran into 2 problems. You have to press the button twice to get it
    >> to work and I can't figure out how to get an answer (OK or Cancel)
    >> from it.
    >>
    >> Here is the onClick function:
    >>
    >> sub Resume_Click(sender as Object, e as eventArgs)
    >> btnResume.Attributes("onclick") = "javascript:return " & _
    >> "confirm('Are you sure you want to delete FAQ #?')"
    >> end sub
    >> The linkbutton is:
    >>
    >> Would you like to submit a <asp:LinkButton id="btnResume"
    >> Text="Resume" onClick="Resume_Click" runat="server"/>&nbsp;?
    >>
    >> What am I missing?
    >>
    >> Thanks,
    >>
    >> Tom

    >
    > What you want to do is set the onclick attribute in the load or pre
    > render. Then handle the click action in the Resume_Click method (ie, in
    > this case, looks like you want to delete a faq entry, do it there).


    It works now.

    I understand what Scott was doing now. You have to set it before the
    routine is called. In my case, I was setting it in the routine I was
    calling.

    Actually, I wasn't deleting an faq entry, just using the button Scott set
    up, just to get it to work.

    Thanks,

    Tom
     
    tshad, Jan 31, 2005
    #4
  5. BTW, here's more information and examples:
    http://SteveOrr.net/Articles/ClientSideSuite.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:O7KKGB%...
    > Take the code out of the Resume_Click event and put it in the Page_Load
    > event.
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    > "tshad" <> wrote in message
    > news:...
    >>I was looking at Scott Mitchells article:
    >>http://aspnet.4guysfromrolla.com/articles/090402-1.2.aspx the tells how to
    >>call a messagebox from a button and can almost get it to work but ran into
    >>2 problems. You have to press the button twice to get it to work and I
    >>can't figure out how to get an answer (OK or Cancel) from it.
    >>
    >> Here is the onClick function:
    >>
    >> sub Resume_Click(sender as Object, e as eventArgs)
    >> btnResume.Attributes("onclick") = "javascript:return " & _
    >> "confirm('Are you sure you want to delete FAQ #?')"
    >> end sub
    >>
    >> The linkbutton is:
    >>
    >> Would you like to submit a <asp:LinkButton id="btnResume"
    >> Text="Resume" onClick="Resume_Click" runat="server"/>&nbsp;?
    >>
    >> What am I missing?
    >>
    >> Thanks,
    >>
    >> Tom
    >>

    >
    >
     
    Steve C. Orr [MVP, MCSD], Jan 31, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    882
    Kevin Spencer
    May 17, 2005
  2. Chris Ritchey
    Replies:
    7
    Views:
    488
    emerth
    Jul 10, 2003
  3. Chris Ritchey

    Generating a char* from a linked list of linked lists

    Chris Ritchey, Jul 9, 2003, in forum: C Programming
    Replies:
    7
    Views:
    477
    emerth
    Jul 10, 2003
  4. fool
    Replies:
    14
    Views:
    518
    Barry Schwarz
    Jul 3, 2006
  5. joshd
    Replies:
    12
    Views:
    678
    John Carson
    Oct 2, 2006
Loading...

Share This Page