problem with own defined procedure

Discussion in 'ASP .Net' started by Chris, Jun 9, 2007.

  1. Chris

    Chris Guest

    Hi,

    i have a formview in Insert mode.
    when a new record is inserted, the text of a textbox becomes: "ok".
    Instead of using the ItemInserted or ItemInserting, i use my own procedure
    like this:

    Protected Sub myproc((ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.FormViewInsertedEventArgs)
    TextBox1.Text = "ok"
    End Sub

    aspx file:
    <InsertItemTemplate>
    ......
    <asp:LinkButton ID="InsertButton" runat="server" OnClick="myproc"
    CausesValidation="True" CommandName="Insert" Text="Insert">
    </asp:LinkButton>
    ......
    </InsertItemTemplate>

    But this gives an error (not same signature ...)

    This second example works:
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="myproc2" />

    Protected Sub myproc2(ByVal sender As Object, ByVal e As System.EventArgs)


    My questions:
    1)why does my first example not work and my second does well?
    2) how to correct the first example?

    Thanks you very much
    Chris
    Chris, Jun 9, 2007
    #1
    1. Advertising

  2. Chris wrote:
    > Hi,
    >
    > i have a formview in Insert mode.
    > when a new record is inserted, the text of a textbox becomes: "ok".
    > Instead of using the ItemInserted or ItemInserting, i use my own procedure
    > like this:
    >
    > Protected Sub myproc((ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.FormViewInsertedEventArgs)
    > TextBox1.Text = "ok"
    > End Sub
    >
    > aspx file:
    > <InsertItemTemplate>
    > .....
    > <asp:LinkButton ID="InsertButton" runat="server" OnClick="myproc"
    > CausesValidation="True" CommandName="Insert" Text="Insert">
    > </asp:LinkButton>
    > .....
    > </InsertItemTemplate>
    >
    > But this gives an error (not same signature ...)
    >
    > This second example works:
    > <asp:Button ID="Button1" runat="server" Text="Button" OnClick="myproc2" />
    >
    > Protected Sub myproc2(ByVal sender As Object, ByVal e As System.EventArgs)
    >
    >
    > My questions:
    > 1)why does my first example not work and my second does well?


    The OnClick event doesn't send a FormViewInsertedEventArgs object to the
    event handler.

    > 2) how to correct the first example?


    Use EventArgs instead, just like in the second example.

    --
    Göran Andersson
    _____
    http://www.guffa.com
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Jun 9, 2007
    #2
    1. Advertising

  3. Chris

    Chris Guest

    Hi, thanks for replying..
    It works now (of course).
    One more remark:
    I guess what the OnClick sends to the procdure is function of the clicked
    object, right?
    But how can i know what the OnClick sends to the procedure? Does it exist a
    list of that for each clickable control or something ..?

    For instance: a click on an Image_button like here, what does that send to
    the procedure? mean: how do i have to make the declaration of the
    procedure?
    <asp:ImageButton ID="ImageButton1" runat="server" OnClick="myproc"
    ImageUrl="~/logos/batman.png" /><br />

    Thanks


    "Göran Andersson" <> schreef in bericht
    news:...
    > Chris wrote:
    >> Hi,
    >>
    >> i have a formview in Insert mode.
    >> when a new record is inserted, the text of a textbox becomes: "ok".
    >> Instead of using the ItemInserted or ItemInserting, i use my own
    >> procedure like this:
    >>
    >> Protected Sub myproc((ByVal sender As Object, ByVal e As
    >> System.Web.UI.WebControls.FormViewInsertedEventArgs)
    >> TextBox1.Text = "ok"
    >> End Sub
    >>
    >> aspx file:
    >> <InsertItemTemplate>
    >> .....
    >> <asp:LinkButton ID="InsertButton" runat="server" OnClick="myproc"
    >> CausesValidation="True" CommandName="Insert" Text="Insert">
    >> </asp:LinkButton>
    >> .....
    >> </InsertItemTemplate>
    >>
    >> But this gives an error (not same signature ...)
    >>
    >> This second example works:
    >> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="myproc2"
    >> />
    >>
    >> Protected Sub myproc2(ByVal sender As Object, ByVal e As
    >> System.EventArgs)
    >>
    >>
    >> My questions:
    >> 1)why does my first example not work and my second does well?

    >
    > The OnClick event doesn't send a FormViewInsertedEventArgs object to the
    > event handler.
    >
    >> 2) how to correct the first example?

    >
    > Use EventArgs instead, just like in the second example.
    >
    > --
    > Göran Andersson
    > _____
    > http://www.guffa.com
    Chris, Jun 9, 2007
    #3
  4. Chris wrote:
    > Hi, thanks for replying..
    > It works now (of course).
    > One more remark:
    > I guess what the OnClick sends to the procdure is function of the clicked
    > object, right?


    As far as I know, no Click events send any extra information to the handler.

    > But how can i know what the OnClick sends to the procedure? Does it exist a
    > list of that for each clickable control or something ..?


    If an event is sent any extra information, it will use some other class
    than EventArgs.

    > For instance: a click on an Image_button like here, what does that send to
    > the procedure? mean: how do i have to make the declaration of the
    > procedure?
    > <asp:ImageButton ID="ImageButton1" runat="server" OnClick="myproc"
    > ImageUrl="~/logos/batman.png" /><br />


    The easiest way is to use the designer in Visual Studio. If you add the
    event in the designer, it will create a method stub with the correct
    parameters.

    Otherwise you can look up the events in the documentation.

    --
    Göran Andersson
    _____
    http://www.guffa.com
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Jun 10, 2007
    #4
  5. Chris

    Chris Guest

    thanks

    "Göran Andersson" <> schreef in bericht
    news:...
    > Chris wrote:
    >> Hi, thanks for replying..
    >> It works now (of course).
    >> One more remark:
    >> I guess what the OnClick sends to the procdure is function of the clicked
    >> object, right?

    >
    > As far as I know, no Click events send any extra information to the
    > handler.
    >
    >> But how can i know what the OnClick sends to the procedure? Does it exist
    >> a list of that for each clickable control or something ..?

    >
    > If an event is sent any extra information, it will use some other class
    > than EventArgs.
    >
    >> For instance: a click on an Image_button like here, what does that send
    >> to the procedure? mean: how do i have to make the declaration of the
    >> procedure?
    >> <asp:ImageButton ID="ImageButton1" runat="server" OnClick="myproc"
    >> ImageUrl="~/logos/batman.png" /><br />

    >
    > The easiest way is to use the designer in Visual Studio. If you add the
    > event in the designer, it will create a method stub with the correct
    > parameters.
    >
    > Otherwise you can look up the events in the documentation.
    >
    > --
    > Göran Andersson
    > _____
    > http://www.guffa.com
    Chris, Jun 10, 2007
    #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. Stefan Siegl
    Replies:
    1
    Views:
    772
  2. Mike P
    Replies:
    0
    Views:
    3,299
    Mike P
    Jun 19, 2006
  3. Saverio M.
    Replies:
    0
    Views:
    512
    Saverio M.
    Jul 3, 2006
  4. Oodini
    Replies:
    1
    Views:
    1,768
    Keith Thompson
    Sep 27, 2005
  5. David Filmer
    Replies:
    17
    Views:
    259
    J. Romano
    Aug 18, 2004
Loading...

Share This Page