By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,423 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

problem with own defined procedure

P: n/a
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.FormViewInsertedEventArg s)
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
Jun 9 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.FormViewInsertedEventArg s)
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
Jun 9 '07 #2

P: n/a
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" <gu***@guffa.comschreef in bericht
news:uR**************@TK2MSFTNGP06.phx.gbl...
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.FormViewInsertedEventAr gs)
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

Jun 9 '07 #3

P: n/a
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
Jun 9 '07 #4

P: n/a
thanks

"Göran Andersson" <gu***@guffa.comschreef in bericht
news:u2**************@TK2MSFTNGP03.phx.gbl...
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

Jun 10 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.