I am new to both jQuery/AJAX and have a problem where I’m using the jQuery ui tabs. Basically in each tab I load their separate .aspx pages and attempt to do the regular processing work. (It loads correctly) My problem is that I have a button on that loaded tab and whenever the button is click, it attempts to process the request (I want to process the tab without reloading the entire page) – but the first issue right now is that I am getting an error saying…”Server Error in ‘/’ Application. (The .aspx pages is in their own file directory – and that may be the error?) Below is the code I’m currently using. Any help or ideas would be appreciated! Thanks!
<div id="tabs">
<ul>
<li><a href="/MemberPages/tab1/tab1.aspx">TAB1</a></li>
<li><a href="/MemberPages/tab2/tab2.aspx">TAB2</a></li>
<li><a href="/MemberPages/tab3/tab3.aspx">TAB3</a></li>
<li><a href="/MemberPages/tab4/tab4.aspx">TAB4</a></li>
<li><a href="/MemberPages/tab5/tab5.aspx">TAB5</a></li>
<li><a href="/MemberPages/tab6/tab6.aspx">TAB6</a></li>
</ul>
<br />
</div>
<script type="text/javascript" src="scripts/jquery-1.9.0.js"></script>
<script type="text/javascript" src="scripts/script.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.10.0.custom.min.js"></script>
<script type="text/javascript">
$(function () {
$("#tabs").tabs({
beforeLoad: function (event, ui) {
ui.jqXHR.error(function () {
ui.panel.html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo.");
});
}
});
});
——Purchasing aspx back-end
Protected Sub tp_btn_Process_Click(ByVal sender As Object, ByVal e As EventArgs) Handles tp_btn_Process.Click
'database code for insertion
End Sub
You can not load an aspx page via ajax, and wait the functions and the JavaScript and the buttons to work as if you run it alone.
Why ? because you have a basic page with a form tag, and inside that you fully load one more different page with a new form – and the full struct is now a mess, you have two viewstates, one post form inside the other and other stuff like that.
Now if you make any post back, the post back data is a mess and the code behind will not accept it.
An alternative if you still like to load the full page in a tab, is to use iframes and not ajax. Iframe is like a full page inside a page, with out mixing the one post with the other.
Similar: how to use iframe instead of div with jquery ui tabs?