Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 967789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:22:36+00:00 2026-05-16T02:22:36+00:00

I have a LinkButton within a User Control and it has handled with: Private

  • 0

I have a LinkButton within a User Control and it has handled with:

Private Sub LoginLinkLinkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginLinkLinkButton.Click
        Response.Redirect("/", True)
End Sub

On certain ASPX pages I would like to handle the click from the page’s code behind, opposed to within the user control. How do I override the handle within the control from the parent’s code behind page?

Update:
Based on the answer, I have the updated the User Control:

Public Event LoginLinkClicked As OnLoginClickHandler
Public Delegate Sub OnLoginClickHandler(ByVal sender As Object, ByVal e As EventArgs)

[...]

Private Sub LoginLinkLinkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginLinkLinkButton.Click
        **If OnLoginClickHandler IsNot Nothing Then**
            RaiseEvent LoginLinkClicked(Me, e)
        Else
            Response.Redirect("/", True)
        End If
End Sub

The problem is determining the correct syntax for the if line because the above is invalid.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:22:37+00:00Added an answer on May 16, 2026 at 2:22 am

    You’ll have to expose a new event from the user control. Apologies as the following code is all in C# and it’s been a long time since I touched VB.Net, but you should get the idea:

    You can use a delegate event by adding the following to your UserControl:

    public event OnLoginClickHandler LoginClick;
    public delegate void OnLoginClickHandler (object sender, EventArgs e);
    

    Then call the following to your LinkButton Click event:

    protected void LoginLinkLinkButton_Click(object sender, EventArgs e)
    {
        // Only fire the event if there's a subscriber
        if (OnLoginClickHandler != null) 
        {
            OnLoginClickHandler(sender, e); 
        }
        else
        {
            // Not handled, so perform the standard redirect
            Response.Redirect("/", true);
        }
    }
    

    You can then just hook up into this within your aspx markup:

    <asp:LinkButton runat="server" ID="Foo" OnLoginClick="Foo_LoginClick" />
    

    And your server side event handler on your Page will be as follows:

    protected void Foo_LoginClick_Click(object sender, EventArgs e)
    {
        // This event was fired from the UserControl
    }
    

    UPDATE

    I think this is how you translate the event subscription check to VB.Net:

    If LoginClick IsNot Nothing Then
        RaiseEvent LoginClick(sender, e) 
    End If 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview within an updatepanel which allows paging and has a linkbutton
i have created Array of Linkbutton and when user click on link button it
I have a LinkButton server control which have some attached method in OnClick Event
I am using a accordion control which has nested gridviews within the content section
I have a Web User Control containing a FormView . The formview shows details
I have a LinkButton where I use the OnClientClick property to ask the user
I have a Page which has a Control on it with 2 textboxes (username
I have this linkbutton within a datalist and I'm trying to get access to
I have a LinkButton that has to postback to perform some logic. Once it
I have a linkbutton in a gridview control in my asp.net app that generates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.