Showing posts with label clicked. Show all posts
Showing posts with label clicked. Show all posts

Monday, March 26, 2012

Tab Control Change Tab Colors

I have a customer that wants the Tab Control to have specific colors for the tabs depending on which tab is clicked. I have been able to use the CssClass to get the hover to be the way they would like but the active tab they would like it to be a different color.

I have attempted to write VB behind code as follows

sub onTabChange(byval sender as object, byval e as system.eventargs)

Select Case TabContainer1.ActiveTab

Case 1

TabContainer1.CssClass = "ajax__tab_tab1"

Case 2

......

end sub

I have the Sub as the onActiveTabChange property of the tab control. I do not get any debugging stop in the code behind page or any indication that there is a call to the sub from the control.

I just need a way to change the colors on each tab depending on which tab is active.

Hi,

Please make sure the AutoPostBack property of the Tab control is set to true.

If this doesn't work, please post a stripped version of your page here.


The autopostback property was the resolution

Thank you.

Tab Extender question

Anyone know how to show a busy mouse cursor when one of the tabs is clicked on?You mean for the AJAX to use the UpdateProgress? a busy mouse means the user cannot click anything else, pretty annonying on the web. Best practise in AJAX is to show the UpdateProgress. Use the UpdatePanel with the UpdateProgress and you are in business

Saturday, March 24, 2012

Tabbing out of a textbox...

Just a word of warning - I am not very familiar with Ajax.

I have a few textboxes and a button within an update panel. When the button is clicked some data is retrieved (using Ajax) and some of the textboxes are filled with that data. I would like to remove the button click step, and instead have that data retrieved when the user leaves the first textbox. So, the user is in a name textbox. They type "Billy Bob," and then tab out to the next textbox (or click out of it to another textbox), at which time Ajax does it's asynchronous stuff to retrieve the data from the server for that name. Is this possible to do?

Thanks in advance!

You could try the TextChanged event of the first TextBox, remember to set theAutoPostBack value to true in the TextBox to generate a postback when you tab out of the TextBox.

hello guys,

yes, this will work, if you're using an updatepanel. anyway, it might not "feel right" to the user since the contents that are inside the panel will be refreshed (which meaans that he migh be writing something on another textbox and then when he looks at it, everything has been "replaced" by the contents sent from the server...


Absolutely right, I prefer to use WebServices or pagemethods to do something like this, infact I don't use UpdatePanels at all in my application for this (and other reasons.), but I think he is using an UpdatePanel at the moment.

Thank you both for your help. I was able to get it to work by using the textbox as the trigger.

Luis, I understand what you're saying about the workflow not feeling right. There are other underlying problems within this page (I didn't originally design it though!) and what it does that made me look at doing this as an option to fix some of those problems. But the more I look at it, the more I think that it just doesn't "feel right." =)

I probably won't implement this solution in the end. Thanks for the help!

TabContainer + ActiveTabChanged + __doPostBack Problem

I have a tabcontainer that i want to postback only when certain tabs are clicked (lets call them "postback tabs")

Here is the setup:

<ajax:UpdatePanel ID="upOuter" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<act:TabContainer ID="TabContainer1" runat="server" CssClass="MyTabStyle" ActiveTabIndex="0" OnClientActiveTabChanged="ActiveTabChanged">
....
....

<script language="javascript" type="text/javascript"
function ActiveTabChanged(sender, args) {
var ht = sender.get_activeTab().get_headerText();
if ((ht =="TabHeader1") || (ht =="TabHeader2") || (ht =="TabHeader3") ){
__doPostBack('<%= tabcontainer1.ClientID %>', sender.get_activeTab().get_headerText());
}
}
....
....

Server Side:

Protected Sub TabContainer1_ActiveTabChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles TabContainer1.ActiveTabChanged

If TabContainer1.ActiveTab.HeaderText = "TabHeader1"Then
....
....
End If
If TabContainer1.ActiveTab.HeaderText = "TabHeader2"Then
....
....
End If
If TabContainer1.ActiveTab.HeaderText = "TabHeader1"Then
....
....
End If
End Sub

This actually works quite well except in the following case:

Step 1. I click on one of the postback tabs

Step 2. Click on a non-postback tab

Step 3. Click back on the tab from step 1.

When I do this, the client side script runs, but the postback never happens. If on step 2, i clicked on a postback tab, everything works fine. Or, if on step three I click on a different postback tab than in step 1, everything works fine.

Any ideas?

Figured out the problem. The postback IS happening, but the server-side activetabchanged event was not firing. The reason for this is that when I clicked on a non-postback tab, the server was not notified of the change in activetab. So, following the steps in the original post, when I click back on to the postback tab in step 3 (the same as the postback tab in step 1), the server thinks the active tab is still the same - since it was not notified of the change in step 2. Hence, ActiveTabChanged does not fire on the server-side.