Solved

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

Posted on 2007-11-14
16
251 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
  • 9
  • 7
16 Comments
 
LVL 16

Accepted Solution

by:
McExp earned 500 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now