Reputation:
I have an ASPX file with this button:
<asp:button id="cmdPartnerInfo" runat="server" Font-Bold="True"
Text="Partner Info" TabIndex="3">
</asp:button>
And in the ASPX.VB file I have this Sub:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cmdPartnerInfo.Attributes.Add("onclick", "return ShowPartnerContatcInfo();")
imgStaff.Attributes.Add("onclick", "return AddStaffSelection();")
lblDt.Text = ""
... snip ...
End Sub
However, there is a squiggly line under cmdPartnerInfo
and the message is:
Error 38 'cmdPartnerInfo' is not declared. It may be inaccessible due to its
protection level.
So it looks like the code in the vb file doesn't see the asp control in the aspx page.
Any help figuring out why this is happening is appreciated.
Thanks! Eric
UPDATE: These are the two directives at the top of the ASPX page.
<%@ Register TagPrefix="Card" TagName="Banner" Src="~/banner.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" CodeFile="projectpartlog.aspx.vb" Inherits="Project_and_Partners_Log" %>
Upvotes: 2
Views: 1615
Reputation: 12351
<%@ Page Language="vb" AutoEventWireup="false" CodeFile="projectpartlog.aspx.vb" Inherits="Project_and_Partners_Log" %>
This directive means:
projectpartlog.aspx.vb
The Class name in the projectpartlog.aspx.vb
file should be Project_and_Partners_Log
Partial Class Project_and_Partners_Log
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub cmdPartnerInfo_Click(sender As Object, e As System.EventArgs) Handles cmdPartnerInfo_Click.Click
'Code.....
End Sub
End Class
Upvotes: 1
Reputation: 1631
<%@ Page
and ensure that you behind class
belongs to you aspx file. Upvotes: 3
Reputation: 32604
You need to check your page directive.
<%@ Page Language="VB" MasterPageFile="~/Master/Mater.master" AutoEventWireup="false"
CodeFile="Test.aspx.vb" Inherits="Test" %>
Check to see if the CodeFile property is set to the proper code file.
Upvotes: 0
Reputation: 28548
I think you have converted your button to private add a new Button and remove it and then try.
Upvotes: 0
Reputation: 3045
does your ASPX file has declaration of page directive having "CodeFile/Inherits" attribute? e.g. <@Page CodeFile="XYZ.aspx.vb" Inherits="XYZ" >
Upvotes: 2