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 700553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:30:40+00:00 2026-05-14T03:30:40+00:00

I have a control which has a button on it. All the button does

  • 0

I have a control which has a button on it. All the button does is redirect the user to another page. On this control I have another control which just display some stuff, nothing fancy. When I click on the button, it does nothing. When I remove or comment out the other control, the button event works. Is this by design? I am not sure how to fix it or what is causing it.

ControlA.ascx contains a button with an event like so:

protected void Button1_Click(object sender, EventArgs e)
{
    Response.Redirect("~/Home.aspx");
}

ControlA.ascx contains another control inside of it, lets call it ControlB.ascx.

The Button1 click event does not fire when ControlB.ascx is in ControlA.ascx, but when I remove it or take it out, Button1 event fires and it goes to Home.aspx. This does not only happen for Button1, if I decide to add a second button and create an event for it, if ControlB is in ControlA, the second button event won’t fire either.

ControlA.asx markup and code:

<div>
    <asp:Button runat="server" ID="Button1" Text="Register 2" 
                           onclick="Button1_Click" />
</div>
<div>
    <uc:ControlB ID="ControlB" runat="server" />
</div>

protected void Button1_Click(object sender, EventArgs e)
{
    Response.Redirect("~/Home.aspx");
}

ControlB.ascx markup:

<div>
  <p>I am control B</p>
  <p>
     <sbi:SexyLinkButton ID="SexyLinkButton1" runat="server" Text="Go Home" 
                         PostBackUrl="~/home.aspx" />

      <asp:Button runat="server" ID="Button1" Text="Register 2" 
                           onclick="Button1_Click" />

</p>
</div>

As stated before, Button1_Click does not fire if ControlB is inside ControlA, but if I remove ControlB or comment it out, Button1_Click fires.

I figured something out:

ControlB.ascx had a button on it called SexyButton ( didn’t create this, someone else did, lol) and when I removed that from ControlB, ControlA’s button worked. I put an asp.net Button in controlB and it worked, so it has something to do with the SexyButton control.

If I put an asp.net button on ControB along with the SexyLinkButton, the event for Button1 on ControlB does not work.

SexyLinkButton.cs – If I put the PostBackUrl on the SexyLinkButton, asp.net button events don’t fire. Here is the code the SexyLinkButton.cs:

public class SexyLinkButton : LinkButton
{
    private List<string> Css = new List<string> ();

    public string IconCssClass { get; set; }
    public SizeEnum Size { get; set; }

    public SexyLinkButton()
    {
        Size = SizeEnum.Normal;
    }

    protected override void Render(System.Web.UI.HtmlTextWriter writer)
    {
        if (!string.IsNullOrEmpty(CssClass)) Css.Add(CssClass);             // User added Css
        Css.Add("sbi-button");                                              // Standard Css for button
        if (Size != SizeEnum.Normal) Css.Add(Size.ToString().ToLower());    // Size Css

        // Nested spans per design and css requirements
        HtmlGenericControl span1 = new HtmlGenericControl("span");
        HtmlGenericControl span2 = new HtmlGenericControl("span");

        // Nested span only for icon
        if (!string.IsNullOrEmpty(this.IconCssClass))
        {
            HtmlGenericControl btnspan = new HtmlGenericControl("span");
            btnspan.Attributes.Add("class", IconCssClass.Replace(".", string.Empty));
            btnspan.InnerHtml = this.Text;
            span2.Controls.Add(btnspan);
        }
        else
        {
            span2.InnerHtml = this.Text;
        }

        CssClass = string.Join(" ",Css.ToArray());
        this.Text = "";
        span1.Controls.Add(span2);
        this.Controls.Add(span1);

        base.Render(writer);
    }

    public enum SizeEnum
    {
        Normal,
        Medium,
        Large
    }
}
  • 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-14T03:30:41+00:00Added an answer on May 14, 2026 at 3:30 am

    What’s probably happening is that your “SexyLinkButton” control is causing a javascript error that’s preventing your button’s postback. Check your browser’s error console to see if any javascript errors are being generated. Also, try substituting a standard LinkButton control instead of the SexyLinkButton to see if that fixes it.

    Edit: looks like it’s actually a form issue with the PostBackUrl.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 529k
  • Answers 529k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use the Python OS module. You can run… May 16, 2026 at 11:17 pm
  • Editorial Team
    Editorial Team added an answer If you need to replicate the tests across controllers, you… May 16, 2026 at 11:17 pm
  • Editorial Team
    Editorial Team added an answer You are supposed to use the Secant Method: http://en.wikipedia.org/wiki/Secant_method Follow… May 16, 2026 at 11:17 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a button in a Nib based view which does not behave like
I have a form, myForm, which has KeyPreview set to true. The idea is
I have some fields to be validated on the server (CustomValidator) which is in
I have a page that has two drop down lists on it and a
On my master page , I have Search textbox and Search Button. On My
I have a webpage that requires login. Once a user has logged in I
i have generated a Linq to Sql class which looks like this. so i
This problem has been solved thanks to your suggestions. See the bottom for details.
Chart on reportviewer does not load unless i click view report button when combolist
I have a winforms app and the main (and only) form has several buttons.

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.