1

I can't get the OnClick method for the button to fire

The button:

<asp:Button ID="postButton" runat="server" 
   Text="Create Thread" OnClick="postButton_Click" />

EDIT: postButton_Click is a code behind(server side) C#

After a bit of trial and error i found out that the button does fire when the following line is removed:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"  
   type="text/javascript"></script>

The scripts are loaded in this order:

<link href="../ajax/jquery-ui-1.8.2.custom.css" 
   rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" 
   type="text/javascript"></script>
<script src="../ajax/jquery-ui-1.8.2.custom.min.js" 
   type="text/javascript"></script>

Changing the jQuery version does not help.

I have the exact same code on another page and it works fine. why does it happen and how can I fix it?

EDIT: Codebehind (breakpoints set in this method fail to trigger)

protected void postButton_Click(object sender, EventArgs e)
{
    Response.Redirect("test.aspx");
}
7
  • what code you have tried.? Commented Mar 12, 2013 at 6:57
  • any error in the console Commented Mar 12, 2013 at 6:58
  • are you using script manager ?? Commented Mar 12, 2013 at 6:59
  • 1
    postButton_Click is server-side method or JavaScript function? Commented Mar 12, 2013 at 7:02
  • its a server-side method Commented Mar 12, 2013 at 7:10

1 Answer 1

2

Ok so i finally found a fix for this problem

The reason that being that the ASP button was inside a JQuery UI dialog. When you use JQuery UI's Dialog plugin to bring up a div as a dialog, it usually pulls the div out of the form to do this and then ASP.Net elements don't work.

Solution which worked: https://stackoverflow.com/a/7673768/1753000

Sign up to request clarification or add additional context in comments.

1 Comment

you must have describe the question and scenario

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.