I was creating Visual Webpart with tabs. On search button execution, my tab moved to 1st tab.
I have a requirement to put the tab on the selected tab either on postback. After googling, I found the solution. Posting the solution with some modification:
On Visual Webpart user control Add:
<asp:HiddenField ID="hidLastTab" runat="server" Value="0" />
Next to add jquery (with latest jquery file)
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs();
$('#tabs').bind('tabsselect', function(event, ui) {
var selectedTab = ui.index;
$("#<%= hidLastTab.ClientID %>").val(selectedTab);
});
});
</script>
in .cs file add the following in OnLoadFunction:
This.Page.ClientScript.RegisterStartupScript(this.GetType(), "selecttab", "$('#tabs').tabs({ selected: " + hidLastTab.Value + " });", true);
And done.
I have a requirement to put the tab on the selected tab either on postback. After googling, I found the solution. Posting the solution with some modification:
On Visual Webpart user control Add:
<asp:HiddenField ID="hidLastTab" runat="server" Value="0" />
Next to add jquery (with latest jquery file)
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs();
$('#tabs').bind('tabsselect', function(event, ui) {
var selectedTab = ui.index;
$("#<%= hidLastTab.ClientID %>").val(selectedTab);
});
});
</script>
in .cs file add the following in OnLoadFunction:
This.Page.ClientScript.RegisterStartupScript(this.GetType(), "selecttab", "$('#tabs').tabs({ selected: " + hidLastTab.Value + " });", true);
And done.
No comments :
Post a Comment