Professional Web Applications Themes

asp.net form post - ASP.NET General

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 ........

  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. #2

    Default Re: asp.net form post

    "LIN" <junkvaluesnotallowedfootball.com> wrote in message
    news:uwJxI5lXDHA.2620TK2MSFTNGP09.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.saunderssurfcontrol.com[/email]


    John Saunders Guest

  3. #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.saunderssurfcontrol.com> wrote in message
    news:uW45F7lXDHA.2352TK2MSFTNGP12.phx.gbl...
    > "LIN" <junkvaluesnotallowedfootball.com> wrote in message
    > news:uwJxI5lXDHA.2620TK2MSFTNGP09.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.saunderssurfcontrol.com[/email]
    >
    >

    LIN Guest

  4. #4

    Default Re: asp.net form post

    "LIN" <junkvaluesnotallowedfootball.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

  5. #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" <junkvaluesnotallowedfootball.com> wrote in message
    news:uwJxI5lXDHA.2620TK2MSFTNGP09.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

  6. #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" <SteveOrr.net> wrote in message
    news:e6xtuhqXDHA.3724tk2msftngp13.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" <junkvaluesnotallowedfootball.com> wrote in message
    > news:uwJxI5lXDHA.2620TK2MSFTNGP09.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

  7. #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]" <carlprspamcop.net> wrote in message
    news:#1OzCXoXDHA.1640TK2MSFTNGP10.phx.gbl...
    > "LIN" <junkvaluesnotallowedfootball.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

  8. #8

    Default Re: asp.net form post

    "LIN" <junkvaluesnotallowedfootball.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]" <carlprspamcop.net> wrote in message
    > news:#1OzCXoXDHA.1640TK2MSFTNGP10.phx.gbl...
    > > "LIN" <junkvaluesnotallowedfootball.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

Similar Threads

  1. How to post form from CFC
    By DARAB in forum Coldfusion - Advanced Techniques
    Replies: 1
    Last Post: June 3rd, 12:52 PM
  2. redirect but with post data - mimick form post behaviour
    By LuckyNinja in forum Coldfusion - Advanced Techniques
    Replies: 4
    Last Post: April 14th, 05:58 PM
  3. How to post some data in form of POST action of forms in asp?
    By Mehdi Mousavi in forum ASP Components
    Replies: 1
    Last Post: September 19th, 05:16 PM
  4. Re-POST a form using ASP
    By Aaron Bertrand - MVP in forum ASP
    Replies: 1
    Last Post: August 22nd, 03:49 PM
  5. ASP, FORMS, POST METHOD And Post with out form(???)
    By Don Glover the younger in forum ASP
    Replies: 2
    Last Post: July 13th, 03:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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