Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Why doesn't my LinkButton on an Inherited ASPX Page fire?

Posted on 2007-11-14
16
Medium Priority
?
261 Views
Last Modified: 2013-12-26
I created a new aspx page (Download.aspx), which inherits from another aspx page (PageApp.aspx).  I added controls such as buttons and LinkButtons.  The click_event routine for the button gets fired w/ no problem, however, the LinkButton click_event does not fire when the inheritance of PageApp is used.  When I comment out the PageApp inheritence and inherit from System.Web.UI.Page, the click_event fires up successfully.  
Please note that the same PageApp is inherited in various other aspx pages in the same project where the linkButtons are used and they're working fine.  

Note, I added the LinkButton by dragging the control on the page and double-clicked on the link to generate the click_event routine.  Again, the routine excutes with the inheritence of Web.UI.Page.

I am stuck with this problem for a day but hitting the wall at this point.  I really appreciate all your help on this.  Thank you so much.
0
Comment
Question by:LISCNY
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
16 Comments
 
LVL 16

Accepted Solution

by:
McExp earned 1500 total points
ID: 20284868
do your @Page tags include the  AutoEventWireup="true" property
0
 

Author Comment

by:LISCNY
ID: 20284982
No, it's set to false.
0
 
LVL 16

Expert Comment

by:McExp
ID: 20285022
this is telling your page that you don't want any help with wiring up the events. if you need them to be off you need to add things like: -

Page.Load +=new EventHandler(Page_Load);  

It's simpler to set the AutoEventWireup to true.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:LISCNY
ID: 20286643
I set the AutoEventWireup = true for both the download.aspx and pageApp.aspx files, but still cannot get the LinkButton event to fire.

My PageApp that's inherited in Download.aspx looks like this:


<%@ Page Language="vb" AutoEventWireup="false" Codebehind="PageApp.aspx.vb" Inherits="PageApp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>PageApp</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">
		<form id="Form1" method="post" runat="server">
		</form>
	</body>
</HTML>

Open in new window

0
 
LVL 16

Expert Comment

by:McExp
ID: 20290889
Is your Download.aspx and PageApp.Aspx both pointing at the same vb CodeBehind file?
0
 

Author Comment

by:LISCNY
ID: 20291010
No,
Download.aspx --> Download.aspx.vb
PageApp.aspx --> PageApp.aspx.vb
0
 
LVL 16

Expert Comment

by:McExp
ID: 20291165
Ok, I was a little confused by your code snippit, that's all you have Codebehind="PageApp.aspx.vb" Inherits="PageApp", yet you claimed it was Download.aspx.

Could you post the aspx and vb file for the page you are having problems with.
0
 

Author Comment

by:LISCNY
ID: 20291291
Here's the code for Down.aspx.vb:
Public Class Down
    Inherits PageApp
 
#Region " Web Form Designer Generated Code "
 
    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
 
    End Sub
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents LinkButton1 As System.Web.UI.WebControls.LinkButton
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label
 
    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object
 
    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub
 
#End Region
 
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not IsPostBack Then
            '	Me.__InitializeWebGrid()
            'me.TextBox1.Text.
 
        End If
    End Sub
 
    Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Dim str As String
        Me.Label2.Text = "This Should Work"
    End Sub

Open in new window

0
 

Author Comment

by:LISCNY
ID: 20291302
Here's the code for the Down.aspx file:
<%@ Page Language="vb" AutoEventWireup="true" Codebehind="Down.aspx.vb" Inherits="beta.Down" enableViewState="True"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>Down</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
	</HEAD>
	<body bottomMargin="1" leftMargin="1" rightMargin="1" MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<TABLE id="Table1" style="Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 8px" height="90%"
				cellSpacing="0" cellPadding="0" width="90%" border="0">
				<TR>
					<TD style="HEIGHT: 14px"></TD>
				</TR>
				<TR>
					<TD style="HEIGHT: 132px" align="left">
						<TABLE id="Table2" cellSpacing="0" cellPadding="0" width="90%" border="0">
							<TR>
								<TD style="WIDTH: 54px; HEIGHT: 17px" align="left"></TD>
								<TD style="HEIGHT: 17px" align="center"><asp:label id="Label1" runat="server" forecolor="White" height="10px" backcolor="#1F3877" width="100%"
										font-names="Arial" font-size="9pt" font-bold="True">Download RPA</asp:label></TD>
							</TR>
							<TR>
								<TD style="WIDTH: 54px" align="left"></TD>
								<TD align="left">
									<asp:LinkButton id="LinkButton1" runat="server">Should work</asp:LinkButton></TD>
							</TR>
							<tr style="FONT-SIZE: 5pt">
								<td style="WIDTH: 1px; HEIGHT: 6px">
									<div style="DISPLAY: inline; WIDTH: 8px; HEIGHT: 5px" ms_positioning="FlowLayout"></div>
								</td>
							</tr>
							<TR>
								<TD style="WIDTH: 54px; HEIGHT: 20px" align="left"></TD>
								<TD style="HEIGHT: 20px" align="left"></TD>
							</TR>
							<TR>
								<TD style="WIDTH: 54px" align="left"></TD>
								<TD align="left"></TD>
							</TR>
							<TR>
								<TD style="WIDTH: 54px" align="left"></TD>
								<TD align="left">
									<asp:Label id="Label2" runat="server">Label</asp:Label></TD>
							</TR>
							<TR>
								<TD style="WIDTH: 54px" align="left"></TD>
								<TD align="left"></TD>
							</TR>
							<TR>
								<TD style="WIDTH: 54px" align="left"></TD>
								<TD align="left"></TD>
							</TR>
						</TABLE>
					</TD>
				</TR>
				<TR>
					<TD align="center"></TD>
				</TR>
				<TR>
					<TD align="center"></TD>
				</TR>
			</TABLE>
		</form>
	</body>
</HTML>

Open in new window

0
 

Author Comment

by:LISCNY
ID: 20292340
FYI, I also found the following code being executed in the page_load event in PageApp.aspx.vb everytime I navigate to a page that inherits PageApp class and that includes the Down.aspx page as well.
Private Sub __RegisterClientScript()
        Dim scriptUrl As String
        If Me.IsRegisterGeneric Then
            scriptUrl = vbCrLf + "<script language=""javascript"" src=""" + URLS.JSGeneric + """></script>"
            Me.RegisterClientScriptBlock("generic_js", scriptUrl)
        End If
 
        If Me.IsRegisterPHTE Then
            scriptUrl = vbCrLf + "<script language=""javascript"" src=""" + URLS.JSTransition + """></script>"
            Me.RegisterStartupScript("transition_js", scriptUrl)
        End If
 
        If Me.IsRegisterDefault Then
            scriptUrl = vbCrLf + "<script language=""javascript"" src=""" + URLS.JSDefault + """></script>"
            Me.RegisterStartupScript("default_js", scriptUrl)
        End If
 
        If URLS.IsDebug Then
            scriptUrl = vbCrLf + "<script language=""javascript"" src=""" + URLS.JSDebug + """></script>"
            Me.RegisterStartupScript("debug_js", scriptUrl)
        End If
    End Sub

Open in new window

0
 
LVL 16

Expert Comment

by:McExp
ID: 20293627
I think your in your Down.aspx.vb class definition is not right, try changing: -

Public Class Down
    Inherits PageApp

to

Partial Class Down
    Inherits PageApp

The way ASP.NET 2.0 works (when using code behind) is that your page provides half the class and the .vb file provides the other half, hence the partial definition. these are then combined into one class for compilation. I'm not sure exactly what happens when you don't use a partial class but I'd guess that it will fail!
0
 

Author Comment

by:LISCNY
ID: 20294063
I found a workaround to this problem for now.  I copied another working page that contains linkButtons and inherits PageApp and renamed it and modified it according to my needs.  All of the working pages use PUBLIC definition.

I'm not exactly sure what's causing this issue but my inclination is that it's the javascript code that's limiting this.  I'm a windows developer so I still have to learn how to debug javascript code to get the full picture.  

Thanks a lot for all your time and assistance.
0
 
LVL 16

Expert Comment

by:McExp
ID: 20299589
I've done some more research and it looks like you only need to use partial classes if you are working with the .20 Framework.

I'm assuming your not?
0
 

Author Comment

by:LISCNY
ID: 20299669
No, I'm not using 2.0
Tags: Microsoft, .NET, 1.1, ASP.NET and VB.NET - codebehind
0
 
LVL 16

Expert Comment

by:McExp
ID: 20299723
yea, should have spotted that.

I've been working with the 2.0 framework for the last 18 months so i've kinda forgotten all about 1.1
0
 

Author Comment

by:LISCNY
ID: 20299774
It's okay, I know what you mean.  I like 2.0 better than 1.1 so when I switch back to coding in 1.1, I take a lot of features for granted and forget that the older version does not have them.  Thank you for your time.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question