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

Question about ImageButton Event

P: n/a
Dear all,

I know that i can add a button with oncommand event "ImageButton_Command" by
using the asp:ImageButton tag in the aspx code.

<asp:ImageButton id="imagebutton1" runat="server"
AlternateText="Sort Ascending"
ImageUrl="images/pict.jpg"
OnCommand="ImageButton_Command"
CommandName="Sort"
CommandArgument="Ascending"/>

But i have problem if i add that button in the codebehind,
Protected WithEvents imagebutton1As System.Web.UI.WebControls.ImageButton

ibtnSetup = New ImageButton

ibtnSetup.ImageUrl() = "icon-setup.gif"

ibtnSetup.CausesValidation = False

ibtnSetup.CommandArgument = drRack.Item("LOCATION_ID")

Protected Sub ibtnSetup_Click(ByVal sender As Object, ByVal e As
CommandEventArgs) Handles ibtnSetup.Command

Console.Write(e.CommandArgument)

End Sub
However, i cannot fire the event by adding the button in the codebehind,
what's wrong with that?

Thank you for your advices.

Regards,
Angus
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
you need to add this event handler..

this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);

Av.

"angus" <an***@angus.com> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl...
Dear all,

I know that i can add a button with oncommand event "ImageButton_Command"
by
using the asp:ImageButton tag in the aspx code.

<asp:ImageButton id="imagebutton1" runat="server"
AlternateText="Sort Ascending"
ImageUrl="images/pict.jpg"
OnCommand="ImageButton_Command"
CommandName="Sort"
CommandArgument="Ascending"/>

But i have problem if i add that button in the codebehind,
Protected WithEvents imagebutton1As System.Web.UI.WebControls.ImageButton

ibtnSetup = New ImageButton

ibtnSetup.ImageUrl() = "icon-setup.gif"

ibtnSetup.CausesValidation = False

ibtnSetup.CommandArgument = drRack.Item("LOCATION_ID")

Protected Sub ibtnSetup_Click(ByVal sender As Object, ByVal e As
CommandEventArgs) Handles ibtnSetup.Command

Console.Write(e.CommandArgument)

End Sub
However, i cannot fire the event by adding the button in the codebehind,
what's wrong with that?

Thank you for your advices.

Regards,
Angus

Nov 18 '05 #2

P: n/a
i am using VB.net
this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);
i know that i have to use above statement if i am using c#.

what if VB.net?
"avnrao" <av*@newsgroups.com> wrote in message
news:Oe**************@TK2MSFTNGP12.phx.gbl... you need to add this event handler..

this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);

Av.

"angus" <an***@angus.com> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl...
Dear all,

I know that i can add a button with oncommand event "ImageButton_Command" by
using the asp:ImageButton tag in the aspx code.

<asp:ImageButton id="imagebutton1" runat="server"
AlternateText="Sort Ascending"
ImageUrl="images/pict.jpg"
OnCommand="ImageButton_Command"
CommandName="Sort"
CommandArgument="Ascending"/>

But i have problem if i add that button in the codebehind,
Protected WithEvents imagebutton1As System.Web.UI.WebControls.ImageButton
ibtnSetup = New ImageButton

ibtnSetup.ImageUrl() = "icon-setup.gif"

ibtnSetup.CausesValidation = False

ibtnSetup.CommandArgument = drRack.Item("LOCATION_ID")

Protected Sub ibtnSetup_Click(ByVal sender As Object, ByVal e As
CommandEventArgs) Handles ibtnSetup.Command

Console.Write(e.CommandArgument)

End Sub
However, i cannot fire the event by adding the button in the codebehind,
what's wrong with that?

Thank you for your advices.

Regards,
Angus


Nov 18 '05 #3

P: n/a
AddHandler ImageButton1.Click, AddressOf ibtnSetup_Click

Av.

"Harry" <ha******@mail.hongkong.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
i am using VB.net
this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);


i know that i have to use above statement if i am using c#.

what if VB.net?
"avnrao" <av*@newsgroups.com> wrote in message
news:Oe**************@TK2MSFTNGP12.phx.gbl...
you need to add this event handler..

this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);

Av.

"angus" <an***@angus.com> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl...
> Dear all,
>
> I know that i can add a button with oncommand event "ImageButton_Command" > by
> using the asp:ImageButton tag in the aspx code.
>
> <asp:ImageButton id="imagebutton1" runat="server"
> AlternateText="Sort Ascending"
> ImageUrl="images/pict.jpg"
> OnCommand="ImageButton_Command"
> CommandName="Sort"
> CommandArgument="Ascending"/>
>
> But i have problem if i add that button in the codebehind,
>
>
> Protected WithEvents imagebutton1As System.Web.UI.WebControls.ImageButton >
> ibtnSetup = New ImageButton
>
> ibtnSetup.ImageUrl() = "icon-setup.gif"
>
> ibtnSetup.CausesValidation = False
>
> ibtnSetup.CommandArgument = drRack.Item("LOCATION_ID")
>
> Protected Sub ibtnSetup_Click(ByVal sender As Object, ByVal e As
> CommandEventArgs) Handles ibtnSetup.Command
>
> Console.Write(e.CommandArgument)
>
> End Sub
>
>
> However, i cannot fire the event by adding the button in the
> codebehind,
> what's wrong with that?
>
> Thank you for your advices.
>
> Regards,
> Angus
>
>



Nov 18 '05 #4

P: n/a
got it....thank you so much.

"avnrao" <av*@newsgroups.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
AddHandler ImageButton1.Click, AddressOf ibtnSetup_Click

Av.

"Harry" <ha******@mail.hongkong.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
i am using VB.net
this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);


i know that i have to use above statement if i am using c#.

what if VB.net?
"avnrao" <av*@newsgroups.com> wrote in message
news:Oe**************@TK2MSFTNGP12.phx.gbl...
you need to add this event handler..

this.ImageButton1.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSetu p_Click);

Av.

"angus" <an***@angus.com> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl...
> Dear all,
>
> I know that i can add a button with oncommand event

"ImageButton_Command"
> by
> using the asp:ImageButton tag in the aspx code.
>
> <asp:ImageButton id="imagebutton1" runat="server"
> AlternateText="Sort Ascending"
> ImageUrl="images/pict.jpg"
> OnCommand="ImageButton_Command"
> CommandName="Sort"
> CommandArgument="Ascending"/>
>
> But i have problem if i add that button in the codebehind,
>
>
> Protected WithEvents imagebutton1As

System.Web.UI.WebControls.ImageButton
>
> ibtnSetup = New ImageButton
>
> ibtnSetup.ImageUrl() = "icon-setup.gif"
>
> ibtnSetup.CausesValidation = False
>
> ibtnSetup.CommandArgument = drRack.Item("LOCATION_ID")
>
> Protected Sub ibtnSetup_Click(ByVal sender As Object, ByVal e As
> CommandEventArgs) Handles ibtnSetup.Command
>
> Console.Write(e.CommandArgument)
>
> End Sub
>
>
> However, i cannot fire the event by adding the button in the
> codebehind,
> what's wrong with that?
>
> Thank you for your advices.
>
> Regards,
> Angus
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.