Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > problem with own defined procedure

Reply
Thread Tools

problem with own defined procedure

 
 
Chris
Guest
Posts: n/a
 
      06-09-2007
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


 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      06-09-2007
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
 
Reply With Quote
 
 
 
 
Chris
Guest
Posts: n/a
 
      06-09-2007
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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      06-09-2007
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
 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      06-10-2007
thanks

"Göran Andersson" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
procedure as argument in procedure AlexWare VHDL 2 10-23-2009 09:14 AM
User-defined exception: "global name 'TestRunError' is not defined" jmike@alum.mit.edu Python 1 07-10-2008 12:37 PM
'Procedure or function <stored procedure name> has too many arguments specified',,,ARGH! Mike P ASP .Net 0 06-19-2006 01:19 PM
Using parenthesis with defined (#if defined(...)) Angel Tsankov C++ 1 04-05-2006 10:00 PM
#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) Oodini C Programming 1 09-27-2005 07:58 PM



Advertisments