Jquery – asp.net button Postback using jQuery

asp.netjquery

I'm in need of doing a post back for an asp.net button inside jQuery modal dialog. The markup I have is something like this

 <div id="content">
        <h1>
            Join Our Community</h1>`enter code here`
        <hr />
       Some Context..
        <br />
        <br />
         Some Context..
        <hr />
        <br />
        <!-- Modal Dialog -->
        <a id="tos" href="#serviceterms" title="You must agree with our tems of service.">Click
            HERE to Agree to our Terms </a>
        <div style="display: none">
            <div id="serviceterms" style="width: 440px; height: 250px; overflow: auto;">
                Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                <br />
                <br />
       Some Context..
                <br />
                <br />
                <hr />
                <input type="button" value="Yes" onclick="ToS_Agree()" />&nbsp;&nbsp;
                <input type="button" value="No" onclick="ToS_NotAgree()" />
            </div>
        </div>
        <br />
        <br />
        <asp:Button ID="HiddenButton" runat="server" Text="Button" OnClick="Button1_Click" />
        <asp:Button ID="SubmitButton" runat="server" Text="Submit Form" Enabled="False" ClientIDMode="Static"
            OnClick="SubmitButton_Click" />
        <br />
        <br />
        <asp:Label ID="LabelResult" runat="server" Text=""></asp:Label>

In the jQuery Section, the code is something like

$(document).ready(function () {

    $("#tos").fancybox({
        'titlePosition': 'inside',
        'modal': 'true',enter code here
        'transitionIn': 'none',
        'transitionOut': 'none'
    });
});

function ToS_Agree() {
    $('#SubmitButton').removeAttr('disabled');
    __doPostBack('<%# HiddenButton.ClientID %>', '')

}

function ToS_NotAgree() {
    $('#SubmitButton').attr('disabled', 'disabled');
    $.fancybox.close();
}       

Problem: When I hit the yes button in the modal dialog, it is posting back correctly. But it directs me to the page_load event body and doesn't go to Button1_Click body. Please help me here. I personally believe that there must be a way to get my desired event body using jQuery.

Best Answer

An expression with the # sign is a data-binding expression. It will only evaluate DataBind() is called. Use the = sign:

__doPostBack('<%= HiddenButton.UniqueID %>', '')