Button1.PerformClick() problem

Discussion in 'ASP .Net' started by Marcin Zmyslowski, Sep 2, 2005.

  1. Hello everybody!

    I have the problem with using Button1.PerformClick() method.

    I don`t know how to call the button. I have been searching the
    newsgroups but I didn`t find any exact description of it.

    I have read that to do that I have to paste the code:

    ---------------------------------------------------

    <%@ Page Language="VB" %>
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Data.SqlClient" %>
    <%@ import Namespace="System.DBNull" %>
    <%@ import Namespace="System.Web.UI.WebControls" %>
    <script runat="server">





    Imports System
    Imports System.Windows.Forms
    Imports System.Drawing


    Public Class MyButton
    Inherits ButtonBase
    Implements IButtonControl
    Private myDialogResult As DialogResult

    Public Sub New()
    ' Make the button White and a Popup style
    ' so it can be distinguished on the form.
    Me.FlatStyle = FlatStyle.Popup
    Me.BackColor = Color.White
    End Sub

    ' Add implementation to the IButtonControl.DialogResult property.
    Public Property DialogResult() As DialogResult Implements
    IButtonControl.DialogResult
    Get
    Return Me.myDialogResult
    End Get

    Set
    If [Enum].IsDefined(GetType(DialogResult), value) Then
    Me.myDialogResult = value
    End If
    End Set
    End Property

    ' Add implementation to the IButtonControl.NotifyDefault method.
    Public Sub NotifyDefault(value As Boolean) Implements
    IButtonControl.NotifyDefault
    If Me.IsDefault <> value Then
    Me.IsDefault = value
    End If
    End Sub

    ' Add implementation to the IButtonControl.PerformClick method.
    Public Sub PerformClick() Implements IButtonControl.PerformClick
    If Me.CanSelect Then
    Me.OnClick(EventArgs.Empty)
    End If
    End Sub

    End Class

    ------------------------------------------------------

    ...and I did it. But I got the error:

    'Imports' statements must precede any declarations.

    I want to call the Button1_Click(sender As Object, e As EventArgs)
    procedure. Previously I wanted to do that by writing Button1_Click() but
    I got the error, so I tried to use Button1.PerformClick() method, but I
    cannot use to completely to make it working.

    Could you help me???

    I would be very grateful

    Thank you in advance
    Marcin from Poland

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Marcin Zmyslowski, Sep 2, 2005
    #1
    1. Advertising

  2. Marcin Zmyslowski

    Pauly T Guest

    You can't have html tags in your code-behind or other class files. If you
    remove all the code before your "Imports" calls, your class should be fine.

    Pauly T
    www.eMembersOnline.com

    "Marcin Zmyslowski" <> wrote in message
    news:OyCZ0$...
    > Hello everybody!
    >
    > I have the problem with using Button1.PerformClick() method.
    >
    > I don`t know how to call the button. I have been searching the
    > newsgroups but I didn`t find any exact description of it.
    >
    > I have read that to do that I have to paste the code:
    >
    > ---------------------------------------------------
    >
    > <%@ Page Language="VB" %>
    > <%@ import Namespace="System.Data" %>
    > <%@ import Namespace="System.Data.SqlClient" %>
    > <%@ import Namespace="System.DBNull" %>
    > <%@ import Namespace="System.Web.UI.WebControls" %>
    > <script runat="server">
    >
    >
    >
    >
    >
    > Imports System
    > Imports System.Windows.Forms
    > Imports System.Drawing
    >
    >
    > Public Class MyButton
    > Inherits ButtonBase
    > Implements IButtonControl
    > Private myDialogResult As DialogResult
    >
    > Public Sub New()
    > ' Make the button White and a Popup style
    > ' so it can be distinguished on the form.
    > Me.FlatStyle = FlatStyle.Popup
    > Me.BackColor = Color.White
    > End Sub
    >
    > ' Add implementation to the IButtonControl.DialogResult property.
    > Public Property DialogResult() As DialogResult Implements
    > IButtonControl.DialogResult
    > Get
    > Return Me.myDialogResult
    > End Get
    >
    > Set
    > If [Enum].IsDefined(GetType(DialogResult), value) Then
    > Me.myDialogResult = value
    > End If
    > End Set
    > End Property
    >
    > ' Add implementation to the IButtonControl.NotifyDefault method.
    > Public Sub NotifyDefault(value As Boolean) Implements
    > IButtonControl.NotifyDefault
    > If Me.IsDefault <> value Then
    > Me.IsDefault = value
    > End If
    > End Sub
    >
    > ' Add implementation to the IButtonControl.PerformClick method.
    > Public Sub PerformClick() Implements IButtonControl.PerformClick
    > If Me.CanSelect Then
    > Me.OnClick(EventArgs.Empty)
    > End If
    > End Sub
    >
    > End Class
    >
    > ------------------------------------------------------
    >
    > ..and I did it. But I got the error:
    >
    > 'Imports' statements must precede any declarations.
    >
    > I want to call the Button1_Click(sender As Object, e As EventArgs)
    > procedure. Previously I wanted to do that by writing Button1_Click() but
    > I got the error, so I tried to use Button1.PerformClick() method, but I
    > cannot use to completely to make it working.
    >
    > Could you help me???
    >
    > I would be very grateful
    >
    > Thank you in advance
    > Marcin from Poland
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
     
    Pauly T, Sep 2, 2005
    #2
    1. Advertising

  3. OK I have checked and I have removed all the code before "Imports"
    calling, but I have just got the following error:
    --------------------------------------------------
    BC30455: Argument not specified for parameter 'e' of 'Public Sub
    Button1_Click(sender As Object, e As System.EventArgs)'.

    Source Error:


    Line 175:
    Line 176:
    Line 177: Button1_Click.PerformClick()
    Line 178:
    Line 179: End Sub
    --------------------------------------------------

    What argument should I write to call this method?

    Thank you in advance
    Marcin from Poland

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Marcin Zmyslowski, Sep 5, 2005
    #3
    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. Andreas Suurkuusk
    Replies:
    0
    Views:
    3,988
    Andreas Suurkuusk
    Jul 27, 2003
  2. Bob
    Replies:
    2
    Views:
    2,792
  3. Jado
    Replies:
    0
    Views:
    140
  4. Jado
    Replies:
    0
    Views:
    114
  5. Mike

    Problem problem problem :( Need Help

    Mike, May 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    551
    Bullschmidt
    May 11, 2004
Loading...

Share This Page