Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default asp.net form post

    hii im working on asp.net and i have a form which has 4 asp.net buttons ech
    time i click on a button the page is posted now i want to know on pageload
    which button has caused the post action.. of the page ...this is would help
    me to write button specific events on tht page ....can any one help out in
    this .....


    LIN Guest

  2. Similar Questions and Discussions

    1. redirect but with post data - mimick form post behaviour
      Any thoughts on how to mimic result of submitting form data via POST Method? I have some code that sanitizes some submitted formfields and i'd like...
    2. How do I POST without a form?
      $name="Bozo The Clown"; $AddressCity="New York City"; How would I "simulate" a POST of those two variables to your web site without having an...
    3. How to post some data in form of POST action of forms in asp?
      Hi there, I need to post some information into an ASP page (mypage.asp), in form of POST action which I do with the following code: 'contents...
    4. Re-POST a form using ASP
      Sure, build a form that posts to itself, and loop through the form collection and put an input type=hidden for each element (except the element(s)...
    5. ASP, FORMS, POST METHOD And Post with out form(???)
      Lets see if I can decribe, this... I have a form on an html page, that will call a remote site with a post method. Prior to running off to the...
  3. #2

    Default Re: asp.net form post

    "LIN" <junkvaluesnotallowed@football.com> wrote in message
    news:uwJxI5lXDHA.2620@TK2MSFTNGP09.phx.gbl...
    > hii im working on asp.net and i have a form which has 4 asp.net buttons
    ech
    > time i click on a button the page is posted now i want to know on pageload
    > which button has caused the post action.. of the page ...this is would
    help
    > me to write button specific events on tht page ....can any one help out in
    > this .....
    Why not simply handle the Click events for all four buttons?
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]


    John Saunders Guest

  4. #3

    Default Re: asp.net form post

    im actually writing a few lines of code on the click event of the button
    ...thts not the problem i want to capture the name of the button wheen the
    form is posted i.e after the button is being clicked..i want to know which
    button has made the form to post..

    "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    news:uW45F7lXDHA.2352@TK2MSFTNGP12.phx.gbl...
    > "LIN" <junkvaluesnotallowed@football.com> wrote in message
    > news:uwJxI5lXDHA.2620@TK2MSFTNGP09.phx.gbl...
    > > hii im working on asp.net and i have a form which has 4 asp.net buttons
    > ech
    > > time i click on a button the page is posted now i want to know on
    pageload
    > > which button has caused the post action.. of the page ...this is would
    > help
    > > me to write button specific events on tht page ....can any one help out
    in
    > > this .....
    >
    > Why not simply handle the Click events for all four buttons?
    > --
    > John Saunders
    > Internet Engineer
    > [email]john.saunders@surfcontrol.com[/email]
    >
    >

    LIN Guest

  5. #4

    Default Re: asp.net form post

    "LIN" <junkvaluesnotallowed@football.com> wrote
    > im actually writing a few lines of code on the click event of the button
    > ..that is not the problem I want to capture the name of the button when the
    > form is posted i.e after the button is being clicked..I want to know which
    > button has made the form to post..
    >
    Lin,
    Given a Button WebControl
    <asp:Button id="Button1" Runat="server" Text="Button1"></asp:Button>

    You can get the Button ID and Text as follows:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim myButton As Button = CType(sender, Button)
    Dim myButtonID As String = myButton.ID
    Dim myButtonName As String = myButton.Text
    End Sub

    --

    Thanks,
    Carl Prothman
    Microsoft ASP.NET MVP
    [url]http://www.able-consulting.com[/url]




    Carl Prothman [MVP] Guest

  6. #5

    Default Re: asp.net form post

    From within your Page_Load event you can look for the names of the buttons
    in the Request.Form collection.
    If the button name is present then you know that button caused the postback.

    --
    I hope this helps,
    Steve C. Orr, MCSD
    [url]http://Steve.Orr.net[/url]


    "LIN" <junkvaluesnotallowed@football.com> wrote in message
    news:uwJxI5lXDHA.2620@TK2MSFTNGP09.phx.gbl...
    > hii im working on asp.net and i have a form which has 4 asp.net buttons
    ech
    > time i click on a button the page is posted now i want to know on pageload
    > which button has caused the post action.. of the page ...this is would
    help
    > me to write button specific events on tht page ....can any one help out in
    > this .....
    >
    >

    Steve C. Orr, MCSD Guest

  7. #6

    Default Re: asp.net form post

    ok now i can find the button in the request.form on page load section ...for
    wht do i check it for ....
    pls note tht the button im using here is image button..pls lemme know

    thanx
    "Steve C. Orr, MCSD" <Steve@Orr.net> wrote in message
    news:e6xtuhqXDHA.3724@tk2msftngp13.phx.gbl...
    > From within your Page_Load event you can look for the names of the buttons
    > in the Request.Form collection.
    > If the button name is present then you know that button caused the
    postback.
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD
    > [url]http://Steve.Orr.net[/url]
    >
    >
    > "LIN" <junkvaluesnotallowed@football.com> wrote in message
    > news:uwJxI5lXDHA.2620@TK2MSFTNGP09.phx.gbl...
    > > hii im working on asp.net and i have a form which has 4 asp.net buttons
    > ech
    > > time i click on a button the page is posted now i want to know on
    pageload
    > > which button has caused the post action.. of the page ...this is would
    > help
    > > me to write button specific events on tht page ....can any one help out
    in
    > > this .....
    > >
    > >
    >
    >

    LIN Guest

  8. #7

    Default Re: asp.net form post

    hii this is working for only a single button when i have more than a single
    button and write the same code below ..both the button's are getting
    executed ....i.e i get the messages from both the buttons ...wht do i do
    now ..and one more thing the button im using here is an image button and not
    a normal button

    thanx


    "Carl Prothman [MVP]" <carlpr@spamcop.net> wrote in message
    news:#1OzCXoXDHA.1640@TK2MSFTNGP10.phx.gbl...
    > "LIN" <junkvaluesnotallowed@football.com> wrote
    > > im actually writing a few lines of code on the click event of the button
    > > ..that is not the problem I want to capture the name of the button when
    the
    > > form is posted i.e after the button is being clicked..I want to know
    which
    > > button has made the form to post..
    > >
    >
    > Lin,
    > Given a Button WebControl
    > <asp:Button id="Button1" Runat="server" Text="Button1"></asp:Button>
    >
    > You can get the Button ID and Text as follows:
    >
    > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Button1.Click
    > Dim myButton As Button = CType(sender, Button)
    > Dim myButtonID As String = myButton.ID
    > Dim myButtonName As String = myButton.Text
    > End Sub
    >
    > --
    >
    > Thanks,
    > Carl Prothman
    > Microsoft ASP.NET MVP
    > [url]http://www.able-consulting.com[/url]
    >
    >
    >
    >

    LIN Guest

  9. #8

    Default Re: asp.net form post

    "LIN" <junkvaluesnotallowed@football.com> wrote
    > hii this is working for only a single button when i have more than a single
    > button and write the same code below ..both the button's are getting
    > executed ....i.e i get the messages from both the buttons ...wht do i do
    > now ..
    > and one more thing the button im using here is an image button and not
    > a normal button
    >
    Given two ImageButton WebControls

    <asp:ImageButton id="ImageButton1" runat="server" ImageUrl="image1.jpg" />
    <asp:ImageButton id="ImageButton2" runat="server" ImageUrl="image2.jpg" />

    The events handlers (and code to get each ID) looks like:

    Private Sub ImageButton1_Click(ByVal sender As System.Object, _
    ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click

    Dim myImageButton As ImageButton = CType(sender, ImageButton)
    Dim myImageButtonID As String = myImageButton.ID
    End Sub

    Private Sub ImageButton2_Click(ByVal sender As System.Object, _
    ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton2.Click

    Dim myImageButton As ImageButton = CType(sender, ImageButton)
    Dim myImageButtonID As String = myImageButton.ID
    End Sub

    When you click on a single ImageButton, the corresponding click event handler fires,
    not both. If you are seeing both click event handlers fire for a single click on one of
    the ImageButton, then post some sample code which repros the problem.

    --

    Thanks,
    Carl Prothman
    Microsoft ASP.NET MVP
    [url]http://www.able-consulting.com[/url]

    > thanx
    >
    >
    > "Carl Prothman [MVP]" <carlpr@spamcop.net> wrote in message
    > news:#1OzCXoXDHA.1640@TK2MSFTNGP10.phx.gbl...
    > > "LIN" <junkvaluesnotallowed@football.com> wrote
    > > > im actually writing a few lines of code on the click event of the button
    > > > ..that is not the problem I want to capture the name of the button when
    > the
    > > > form is posted i.e after the button is being clicked..I want to know
    > which
    > > > button has made the form to post..
    > > >
    > >
    > > Lin,
    > > Given a Button WebControl
    > > <asp:Button id="Button1" Runat="server" Text="Button1"></asp:Button>
    > >
    > > You can get the Button ID and Text as follows:
    > >
    > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles Button1.Click
    > > Dim myButton As Button = CType(sender, Button)
    > > Dim myButtonID As String = myButton.ID
    > > Dim myButtonName As String = myButton.Text
    > > End Sub
    > >
    > > --
    > >
    > > Thanks,
    > > Carl Prothman
    > > Microsoft ASP.NET MVP
    > > [url]http://www.able-consulting.com[/url]
    > >
    > >
    > >
    > >
    >
    >

    Carl Prothman [MVP] Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139