Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button_Click Sub is not a member of ASP.Page_aspx

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
Below is my code which is in my codebehind, and my button which is in the aspx page itself. I get the above error at Compilation time. I do not know what it means. Could you help explain it to me? (I have tried it as Public and Private.)

Code:
Private Sub addImg_Click(ByVal sender As Object, ByVal e As EventArgs) Handles addImg.Click
  Dim yB As Boolean
  If jobNum.Text = "" Then jobNum.Text = newWebNum("w")
  If Request.Form(&quot;radioYb&quot;) <> &quot;None&quot; And Request.Form(&quot;radioYb&quot;) <> &quot;&quot; Then
   yB = True
   If ybjobNum.Text = &quot;&quot; Then ybjobNum.Text = newWebNum(&quot;y&quot;)
  End If
  addRecord(yB)
  img1.Visible = False
End Sub
...
<asp:Button id=&quot;ordLkpBtn&quot; onclick=&quot;ordLkp_Click&quot; runat=&quot;server&quot; Text=&quot;Lookup Job&quot;></asp:Button>
 
Well, heres one thing:

&quot;ordLkp_Click&quot; and &quot;addImg_Click&quot; are not spelled the same.
 
this could be the problem:

your sub is called addImg_Click, but in your asp tag, your onClick event is firing &quot;ordLkp_Click&quot;.

Just to make it consistent, you might want to change the asp tag's id value to be addImg as well.

D
 
Sorry, I have two button event chunks of code. Here is the code it is supposed to be firing:
Code:
 Private Sub ordLkp_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ordLkpBtn.Click
  LoadList()
 End Sub
 
Try this:

Sub ordLkp_Click( s As Object, e As EventArgs )
LoadList()
End Sub

Kris
[pc3]
 
Nope, still:
BC30456: 'ordLkp_Click' is not a member of 'ASP.seniors_aspx'.

Source Error:
Line 25: <asp:Button id=&quot;ordLkpBtn&quot; onclick=&quot;ordLkp_Click&quot; runat=&quot;server&quot; Text=&quot;Lookup Job&quot;></asp:Button>


Code:
 Sub ordLkp_Click(ByVal s As Object, ByVal e As EventArgs)
 LoadList()
End Sub

It's as if it's not looking to the CodeBehind for the Method. Do I have to declare the method
Code:
ordLkp_Click
?


 
make sure this is somewhere at the top of your code behind:

Protected WithEvents ordLkpBtn As System.Web.UI.WebControls.Button

D
 
First, the &quot;proper declaration&quot; is
Protected Sub ....

but that's not what's causing your problem. It's saying that the sub didn't get compiled into your class. Now this can mean a few things:

First, have you compiled it since you added the sub to the code-behind? If not, then do that.

If you have, then I would guess that your inherits=&quot;&quot; statement at the top of your .aspx page isn't properly declared, and therefore isn't being compiled properly.

If that's not the case, then double check the class name on your code-behind. It's going to have to match whatever you declare in the inherits=&quot;&quot; statement.

Are you using VS.NET? If so, then to get that right, the easiest way is to create a new page, let VS set all that up for you, and then paste this stuff in there, compile it, and it should work just fine.

hth
paul
penny1.gif
penny1.gif
 
Where did you get onclick=&quot;ordLkp_Click&quot;? That looks like client side code. Did you code this by hand? Where is the Handles clause as in

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
WAIT A SECOND HERE FELLAS!!!! No body told me that with Code Behind I don't need to specify what to do in the design portion of the page. That Handles, I've seen it, but I didn't realize it replaces the onclick thingy in the component on the page.... Is that the case? Instead of this:
Code:
<asp:Button id=&quot;ordLkpBtn&quot; onclick=&quot;ordLkp_Click&quot; runat=&quot;server&quot; Text=&quot;Lookup Job&quot;></asp:Button>

I put this:
Code:
<asp:Button id=&quot;ordLkpBtn&quot; runat=&quot;server&quot; Text=&quot;Lookup Job&quot;></asp:Button>

And just have the codebehind look for the events with that Handles portion?
 
I use Visual Studio so I did not code anything until I needed to add code to the generated Click Event. I drew a button on the form, renamed it in the Properties Window, opened the code behind Class, selected the button name in the left combo and selected Click in right combo. Bam, instant _Click event handler. Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Cool... Yea, that's how I'm gonna do it from now on, but this is migrating from inline code. Having some problems still... No errors, but the code isn't doing anything. I'll have to step thru.
 
qwert,

if you want to, feel free to post the code in our workspace file area


Just create a new folder in the file area and upload the code pages your having issues with. might be easier for us to solve if we can actually see what you're trying to do.
:)

D

p.s. use the html upload method, not the windows method when it asks you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top