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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:04:42+00:00 2026-05-13T18:04:42+00:00

Having some strange behavior here. I have some XSLT which generates some html with

  • 0

Having some strange behavior here. I have some XSLT which generates some html with a few ASP.NET Link Button Controls

 String mstring = sw.ToString();
 var myctrl = Page.ParseControl(mstring);

      foreach (Control Control in myctrl.Controls)
              {
                  if (Control is LinkButton)
                      {
                         LinkButton lb = (LinkButton)Control;
                         lb.OnClientClick = "LoadPromo";

                       }
                          Panel1.Controls.Add(myctrl);
               }  

  protected void LoadPromo(object sender, EventArgs e)
        {
            Console.Write(e.ToString());

        }

now it takes this control:

<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LoadPromo" Text="Get your Free 2" />

and changes it to this when I add an event:

<a onclick="LoadPromo;" id="dnn_ctr954_ViewPromotions_LinkButton2" href=" WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("dnn$ctr954$ViewPromotions$LinkButton2", "", true, "", "", false, true))">Get your Free 2 a>

Now as you can see, it changes the onclick to like javascript instead of the asp.net control.It changes “LoadPromo” to “LoadPromo;”. What can i do to get around this?

Thanks In Advance

Things I have tried:

 lb.Click += LoadPromo;

I get this output:

<a id="dnn_ctr954_ViewPromotions_LinkButton2" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;dnn$ctr954$ViewPromotions$LinkButton2&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">Get your Free 2</a>
  • 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-13T18:04:42+00:00Added an answer on May 13, 2026 at 6:04 pm

    OnClientClick is the name of the property of a server control that eventually renders to an “onclick” attribute. This is meant to invoke a javascript function on the client side. So in this case, it looks fine.

    For the OnClick property, you need to have that match the name of a server-side function in your Page.aspx. I’m not sure why it would even be rendering the onclick attribute for this – perhaps you don’t have a function named “LoadPromo” with the right signature?

    You should have a C# method like this:

    protected void LoadPromo(object sender, EventArgs e)
    {
    
    }
    

    Then you can wire this up to your button by doing

    myLinkButton.Click += LoadPromo;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I'm having some strange trouble with pamie: http://pamie.sourceforge.net/ . I have written a script
I'm having some strange behavior with google plusone button. When a user clicks +1
I'm having some strange behavior where my MPMoviePlayerViewController isn't auto -rotating when the orientation
I've been having some strange errors lately. I have a working install of Git,
I'm having a strange problem with ZeroMQ, in which some messages get stuck, and
I'm having quite a difficulty, figuring out some strange behavior when looping through symbols
I am having some strange problem and its really frustating me. I have a
For some reason my action link behavior sends users to a strange place. I
I am having some very strange ListView behavior when using a StateListDrawable as the

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.