Reputation: 177
Hello everyone I know may be its childish thing in which I am stuck. I am doing work on vb.net project after a long time so I am facing a little issue in which I stuck. I am working on a project in which I have to call a base class function on button click function. However may be I am doing a mistake in it. I have an aspx page which inherits with common.vb file.
Below I’m using the code,
newProduct.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="NewProduct.aspx.vb" Inherits="IES_dashboard.common" %>
<%@ Register TagPrefix="inc" TagName="head" Src="~/include/head.ascx" %>
<%@ Register TagPrefix="inc" TagName="header" Src="~/include/header.ascx" %>
<%@ Register TagPrefix="inc" TagName="sidebar" Src="~/include/sidebar.ascx" %>
newProduct.aspx.vb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Public Class NewProduct
Inherits common
Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCancel.Click
Dim redirect As common = New common()
End Sub
End Class
common.vb code
Imports Microsoft.VisualBasic
Public Class common
Public Function response()
Response.Redirect("main.aspx")
End Function
End Class
I want to call response function on btnCancel_Click. I will be thankful if someone help me in this issue. Thanks in advance.
Upvotes: 1
Views: 169
Reputation: 6398
You made NewProduct inherit from Common. In this case, you can think of NewProduct being 'Common'. There's no need to create an instance of it during btnCancel_Click. You can simply invoke the method available on Common (and therefore on NewProduct):
Public Sub btnCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCancel.Click
response()
End Sub
Upvotes: 2