jquery ui tabs redirecting to ASPX page on postbacks

Posted by neoneo007 on Stack Overflow See other posts from Stack Overflow or by neoneo007
Published on 2009-05-26T14:26:35Z Indexed on 2010/04/23 6:53 UTC
Read the original article Hit count: 389

Filed under:
|
|
|
|

I am being redirected to the actual aspx page when I submit the form. How to avoid the redirection.

Tabs.aspx

<div id="container-1">
        <ul>
            <li><a href="Survey.aspx?group=1"><span>HR</span></a></li>
            <li><a href="Survey.aspx?group=2"><span>Sales</span></a></li>
            <li><a href="Survey.aspx?group=3"><span>Finance</span></a></li>
        </ul>

jquery code in tabs.aspx

<script type="text/javascript">
        $(function() {
            $('#container-1 > ul').tabs();
</script>

Survey.aspx

<form id="form1" runat="server">
<div>
    <asp:Label ID="lblHeading" runat="server"></asp:Label><br />
    <asp:HiddenField ID="hdnGroupId" runat="server" />
    <br />
    1) Question 1        <asp:DropDownList ID="DropDownList1" runat="server">
    </asp:DropDownList>
       
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
    2) Another question:  <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
    <br />
    <br />

    <asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="Save" /><br />

    <div id="Result">Click here for the time.</div>

    <asp:Label ID="lblMessage" runat="server"></asp:Label></div>
</form>

Survey page Code behind

protected void btnSave_Click(object sender, EventArgs e)
{
    if (groupId > 0)
    {
        switch (groupId)
        {
            case 1:
                lblMessage.Text = "HR data is saved.";
                break;
            case 2:
                lblMessage.Text = "Sales data is saved.";
                break;
            case 3:
                lblMessage.Text = "Finance data is saved.";
                break;
            default:
                break;
        }
    }
}

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ui