problem with own defined procedure

C

Chris

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Chris said:
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.
 
C

Chris

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Chris said:
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.
 
C

Chris

thanks

Göran Andersson said:
As far as I know, no Click events send any extra information to the
handler.


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


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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top