Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Wednesday, March 28, 2012

Tab Container within an Update Panel

I am working on a page that contains a grid within an update panel. The user selects an item from the grid, popping up a draggable panel with the details of the item they selected.

I want to be able to have a tab control within the pop up, but am running into some issues. The backgrounds of the tab headers dont show up. It looks to me like the styles arent getting sent to the browser because the control is being added to the page through the update panel. When I move the tab control outside of the update panel, or add another one to the page that is visible on page load it looks fine.

I was about to add another tab container to the page and set the display to none but that seems like a hack. I was wondering if there is any other way to get the styles for the tab container down to the page on load without having to do something like that.

Thanks for the help in advance,
James Hollister
Ascending Integration Inc.
www.AscendingIntegration.com

The tab control should be outside that UpdatePanel or inside a new UpdatePanel to work. Makes sense?

If you, please post the code and let's figure it out.


I'm having the same issue with the TabContainer styles not being sent to the browser, did anyone find a solution for this?

The tab container itself contains ajax functionality

Most Controls that contain built in ajax functionality dont work well in an UpdatePanel because the javascript does not gets send in an update panel during partial updates

You will need to keep the tab container outside of an update panel.

This however causes the problem of the tab container state not being updated from the code behind. For example i was not able to change the active tab from code behind in a partial postback.

The turnaround for this was that i used javascript

the below code shows how exactly

first io create a javascript function to change the active tab index

function ChangeTab(indx)

{

$find('<%=TabContainer1.ClientID%>').set_activeTabIndex(indx)

}

$find('<%=TabContainer1.ClientID%>') gets a reference to the tab container object in the javascript

then called this from code behind using the following

ScriptManager.RegisterStartupScript(Me, updButtonBar.GetType,"KEY","ChangeTab(2);",True)

here the me is the page and updbuttonbar is the update panel . It can be any update panel in the page.

In this way you can manipulate the tab container by calling any of the methods of the tab container javascript object.

If you want to find the listing of the methods save As the page containing the tab container as a complete web page on ur local hard drive

in one of the resources file u can find the methods the javascript object tab container contains or perhaps download the ajax control toolkit source

This ways was good enough for me.

Let me know if it helps

Cheers

Sohail Sayed


No this is not true - UpdatePanel does incremental loading of the scripts.

I'm not able to repro this. On the sample page, I wrap the TabContainer in an UpdatePanel and it works fine.

Can someone please post a repro?


I would do, but the situation in which this problem has arisen for me is a little bit complicated, since i'm building a custom webpart based draggy droppy affair. The TabContainer is in an UpdatePanel, which is in another UpdatePanel, and i'm creating it programatically.

I'll have a quick play, and see if i can get it to happen in a simpler scenario.


Ok, this is a much simplified reproduction of my page, but it causes the "bug". I need to add a TabContainer dynamically as the result of a button press, and in the following conditions, it appears with no styles on it.

<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> </div><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></ContentTemplate></asp:UpdatePanel></ContentTemplate></asp:UpdatePanel> </form></body></html>
 
 
protected void Page_Load(object sender, EventArgs e) { }protected void Button1_Click(object sender, EventArgs e) { AjaxControlToolkit.TabContainer tbc =new AjaxControlToolkit.TabContainer(); AjaxControlToolkit.TabPanel tbp1 =new AjaxControlToolkit.TabPanel(); tbp1.HeaderText ="Test Panel 1"; Literal ltrl1 =new Literal(); ltrl1.Text ="Panel 1 Content"; tbp1.Controls.Add(ltrl1); tbc.Tabs.Add(tbp1); AjaxControlToolkit.TabPanel tbp2 =new AjaxControlToolkit.TabPanel(); tbp2.HeaderText ="Test Panel 2"; Literal ltrl2 =new Literal(); ltrl2.Text ="Panel 2 Content"; tbp2.Controls.Add(ltrl2); tbc.Tabs.Add(tbp2); UpdatePanel2.ContentTemplateContainer.Controls.Add(tbc); }

The problem that I am having along these lines is that when either the TabContainer itself or whatever container it is in (ex. Panel) is set to Visible=false; then on the partial page load the styling is not loaded. From my understanding it adds a <link> to the header when the page is loaded but this doesn't work if the control was not visible when the page was initially rendered. When the TabContainer is rendered everything is there and it works but you can't see the tab but only the HeaderText. All of the styling is lost.

Any idea of how to get around this? My thought was to add the <link> when the page is first loaded but I'm can't find anything about how to do this.

Luke


I'm having the same problem.

If I create a TabContainer dynamically (through OnInit) or initially set the TabContainer.Visible = false, the styling does not load.


Hi,

Unfortunatelly TabContainer does not properly load CSS if it first appears on the page in UpdatePanel with async update postback. However, it is quite easy to solve this, by adding an empty TabContainer somewhere to the page, but utside any UpdatePanel. Empty TabContainer without any Tabs does not render anything noticable to the page, but it loads CSS which is later used by other TabContainers.

So, add a TabContainer without pages to your page and make sure it is not in UpdatePanel and it its Visible = true.

-yuriy
http://couldbedone.blogspot.com


That did the trick. I added the following code and it works just like I want it to.

</asp:UpdatePanel>
<ajaxToolkit:TabContainerID="tabNotUsed"runat="server"Visible="true"/>

Thanks for the help!

Luke

Monday, March 26, 2012

Tab Control doesnt display correctly within User Control

I've tried searching for answers to this but the search facility seems to not be working at the moment, so please forgive me if there are similar posts in here somewhere which I just can't see.

I don't know whether I'm the only person here trying to use these controlkit controls inside my own user controls, but it seems that every time I try I get mysterious problems! I'm dynamically adding Tab Panels to a Tab Container in the Container_Init function. This works beautifully in a straight aspx page, but as soon as I place the Tab Container within an ascx page, I get little white blocks appearing at runtime in front of each Tab "header" area, starting about halfway down each one and slightly offset to the left, so that only the top half of the tab header text is visible. Also there is a solid line (albeit with a tiny gap at the right-hand end) between the active tab header and the corresponding panel, so there is no sense of the header belonging to the active tab.

Any hints anyone?

_Ade.

Well I won't say I've "solved" this problem, but I have come up with a totally bizarre workaround.

By dint of tediously commenting out each element of the supplied css class line by line and rebuilding, I finally realised that the defaultajax__tab_tabclass has a hard-coded height of 13px, and in the specific case where the tab container is contained within a user control, increasing this height to 21px fixes the problem!

Does anyone know what this is all about? Will it come back and bite me again when it wakes up?

_Ade.


Try add the following to your user control:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Good luck.


I added the line and it makes no difference. Unless I change the ajax__tab_tab class Height from 13px to 21px it doesn't display correctly.

_Ade.


Where did you add it to? Try to add it to the page consuming the user control to see if works.


Yep, it worked!

10xvljw8202.


Well actually, it did fix the tab display, but it screwed up the formatting of the rest of the page and every other page in my application!

I'm sticking with resetting the css file to 21px height.

_Ade.


Please help !

I have set the height as 21 px as mentioned, but the tags are still broken.

Is there anybody experience the same problem?

Thanks


Found out the solution finally.

I put the code "<script language='Javascript'>window.resizeTo(screen.width,screen.height); self.moveTo(0,0);</script>" on aspx.vb file.

In order to solve the broken tags problem. remove the code from .aspx.vb file, and put them into .aspx file.

I hope it helps.

Tab control question

Does anyone know how to force the user to "stay" in a tab if they try to click another tab? I'm doing validation but don't want them to be able to move to another tab until required fields are filled out.

Thanks,

Doug

http://forums.asp.net/t/1086839.aspx

This post might help. You can intercept the ActiveTabChanged event and decide whether you want to allow the tab to change or not.

Jason


Thanks for that link but I'm still unsure how to prevent the user from getting to another tab. I tried setting the "ActiveTabIndex" within that event and it still goes to the other tab.Tongue Tied

Does anyone have any sample code that would help me?

Thanks!

Doug


Hi Doug,

You may keep the previous selectedIndex in a variable, and assign it back to TabContainer if validation fails.

For instance:

int previousIndex = 0; // variable storing previously selected index
protected void Page_Load(object sender, EventArgs e)
{
previousIndex = TabContainer1.ActiveTabIndex;
}
protected void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
{
bool validationResult = true;
// compute validationResult
if(!validationResult) // if validation fails
TabContainer1.ActiveTabIndex = previousIndex;
}

Hope this helps.

Saturday, March 24, 2012

Tab Panel Disappears on hover over?

Hi all,

I have a reporting page created in Visual Web Dev 2005. It uses a calendar control to allow a user to select a starting and ending date which fills to separate gridviews that reside in two different tab panels. The datagrids in the panel further break down the data by allowing the user to click on a location (or problem depending on the tab clicked) opening a datagid in the panel and also opening the individual tickets in another datagrid not in the panel.

All works well until I click on the second tab to view the second set of results. It shows the info, but when I move the cursor down into the panel the tab panel disappears! If I click on the tab the info comes back but the same thing happens if I mouse over the second tab.

I'm stumped...

Anybody have any sugesstions?

TabContainer and DropDownList

Hi!

I've got a User Control that contains a DropDownList with AutoPostBack=true and theSelectedIndexChanged event is wired.

I've tested my User Control in a blank .aspx page and it works fine!


Now, if I add this User Control in a TabContainer and run it again, it stoppes behaving as it should: SelectedIndexChanged doesn't trigger and the list is empty after postback.

Has anybody experienced the same kind of problem?

Thanks!

Hi,

Please post your code so i can review it and then give you a logical explanation for this


Hi ,

You could try adding an UpadatePanel inside the Tab and then add the user control inside the Updatepanel.

George

TabContainer and TabPanel

I'm trying to build a fairly customized TabContainer... which contains TabPanels that can be closed or opened by the user (except the first TabPanel which is always available), also with different styles, colors, etc. How can the TabContainer be customized ? And does it support client-side closing/hiding TabPanels ?

Check out the sample:http://www.asp.net/AJAX/Control-Toolkit/Live/Tabs/Tabs.aspx

Check out the section namedTabs Theming for how to style the control.

-Damien


Thanks for the answer... but

What about allowing the user to close/open tabs without using code-behind functions?


I don't believe there is way to hide them client side. You can set theEnabled property though client side according to that link I sent you.

TabPanel Properties
"Enabled - Whether to display the Tab for the TabPanel by default. This can be changed on the client."

-Damien

Wednesday, March 21, 2012

TabContainer and Validator

I'm new to the toolkit... Can you use RequiredFieldValidator to validate a textbox when the user clicks on a different TabPanel in the TabContainer? I imagine that you can write your own JS. Thoughts?

Thanks!!!

Hi,

According to my understanding to your question, you are trying to prevent the other TabPanel from being actived if current TabPanel has validators that fail to validate. Isn't it?

As far as I know, the TabContainer doesn't expose an event that fires before the active panel is changed. So, you may try an alternative method. The basic idea is as follows:

1. Add an activeTabChanged event handler to the TabContainer
2. When a tabPanel is actived, save its index in a global variable
3. In the activeTabChanged handler, check if all Validators in previous tabPanel are valid. If not, set current active index to the index stored in global variable.

You may have the following code:

function pageLoad() {
tc = $find("TabContainer1");
tc.add_activeTabChanged(onChanged);
}

var index = 0;

function onChanged(sender, e) {
tc = $find("TabContainer1");
if( !Page_Validators[0].isvalid ){ // I assume validators[0] is in previous panel here. For practical usage, you may have to implement a strategy to organize validators in different panels
tc.set_activeTabIndex(index);
}
else{
index = tc.get_activeTabIndex(index);
}
}

Though this approach is not that straight, still hope this can helps.

TabContainer drawing issue

I have TabContainer within a panel that is on a usercontrol. The user control is on a page that houses everything in an UpdatePanel. I have many user controls all activated/de-activated when a value changes in a dropdownlist control.

When the page containing the usercontrol is first rendered I have the panel visibility set to false so I see noting from this control as expected. When I trigger the need for the usercontrol I then set the panel visibility to true. This works for all other controls but I wanted to put the new tabs on this control.

The problem is that the TabContainer on this control does not draw anything except the bare controls that are on the first tab with NO styles, colors etc. I maintain a page state enum so that I know what to show the user if they refresh the page completely. If I refresh (F5) the page at this point I now see everything correctly and can use the tabs. Does anyone have a fix for this issue? I am sure it has something to do with my setting the containing panel visibility false to begin with but I cannot seem to find a solution.

The user control setup is basically what I have below, nothing special.

<asp:PanelID="pnlCardSearch"runat="server" visibility="false">
<ajaxToolkit:TabContainerrunat="server"ID="Tabs"Height="150px"OnClientActiveTabChanged="ActiveTabChanged">
<ajaxToolkit:TabPanelrunat="Server"ID="Panel1"HeaderText="Signature and Bio">
<ContentTemplate>
<asp:UpdatePanelID="UpdatePanel1"runat="server">
</asp:UpdatePanel>
<asp:UpdatePanelID="UpdatePanel2"runat="server">
</asp:UpdatePanel>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
</asp:Panel
I'm just trying to get it to work using the tab example at this point.

I know posts like this aren't helpful, but i've got a very similar setup to that described above (usercontrol, updatepanel, tabcontainer), and i'm experiencing the same issue.

I'm adding a tabcontainer programatically, and when it first appears, it has no borders, no tab images, no anything really, yet the functionality still works. When you refresh the page, it appears as normal. In my case, it seems that if you add the tabcontainer during the OnInit event, it renders properly, yet if you add it as the result of a postback event, later in the page cycle, it renders improperly as described above.

If anyone could shed any light on this then i'd be grateful.

Cheers


Hello,

Did you find a solution to your problem? I am having the same problem with the same setup. Could you share the code on how you are mainting state of the page with the Enum and how you activating and deactivating your controls.

Thanks

TabContainer preventing the user from switching tabs if some textbox changed in a previous

Hello,

I have a TabContainer control with 3 tabs. On each tab I dynamically add textboxes. Each one of the textboxes has an OnTextChanged event. What I am trying to do is, to prevent the user from being able to switch between tabs if some of the text has changed in the textboxes, but the save button was not clicked.

So what I really want to do is, to detect when a user clicks on a different tab, then check my current tab see if any of the textboxes were updated and if they were I don't want to allow the other tab to be selected. Can someone please give me some hints or an example of how I can do this?

Thank You,

Vadim


You can hook into the tab changed event as follows:

var tabs = $find('TabsClientID');
tabs.add_activeTabChanged(YourHandler);

In YourHandler, you can do the necessary checks to see if the user should be moving away from a tab and return them to the previous tab if the checks fail. You will need to track the active tab index manually so that you can return them to the correct tab.

Jason


So calling the tabs.add_activeTabChanged(serversideHandler), will cause a postback correct? I will need to be able to pop up an alertbox or something like it notifying the user that they can't switch tabs from the serverEvent. Is there a way to cause some javascript to run from a function on the server?


this is my tab control here:

<cc1:TabContainer ID="tbcSettings" OnActiveTabChanged="ActiveTabChanged" runat="server" Width="300" Height="300">
<cc1:TabPanel ID="tbpGlobal" OnClientClick="ActiveTabChanged" TabIndex="0" BorderWidth="2" runat="server" HeaderText="Global">
<ContentTemplate>
<asp:UpdatePanel ID="upTab_List" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<slc:SettingList ID="settingListGlobal" runat="Server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="tbcSettings" EventName="ActiveTabChanged" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="tbpCommercial" OnClientClick="ActiveTabChanged" TabIndex="1" runat="server" HeaderText="Commercial">
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<slc:SettingList ID="settingListCommercial" runat="Server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="tbcSettings" EventName="ActiveTabChanged" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="tbpMedicaid" OnClientClick="ActiveTabChanged" TabIndex="2" runat="server" HeaderText="Medicaid">
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<slc:SettingList ID="settingListMedicaid" runat="Server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="tbcSettings" EventName="ActiveTabChanged" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>

<script language="javascript">

function ActiveTabChanged(sender, e)
{
__doPostBack('<%= tbcSettings.ClientID %>');
}

</script>

c# code:

protected void ActiveTabChanged(object sender, EventArgs e)
{
//bcSettings.ActiveTabIndex = ((AjaxControlToolkit.TabContainer)sender).ActiveTabIndex;
//((AjaxControlToolkit.TabContainer)sender).
string tabname = tbcSettings.Tabs[((AjaxControlToolkit.TabContainer)sender).ActiveTabIndex].HeaderText;
switch (tabname)
{
case "Global":
stl = settingListGlobal;
break;
case "Commercial":
stl = settingListCommercial;
break;
case "Medicaid":
stl = settingListMedicaid;
break;
default:
break;
}
if (!stl.Saved)
{
string js = @."if (alert('you made changes, do you want to save now'))";
js += "{";
js += "__doPostBack('" + btnSave.ClientID + "');";
js += "}";

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "savepostback", js, true);
}
}


No, the sample code I provided was for clientside handling of the event when the tab is changed...it does not cause a postback. The tab container is supposed to be able to automatically postback when a tab is changed although I have seen some posts that indicate that this might not be happening correctly. Check the forums to see if this is working or not.

Personally, I think it might be a nicer user experience to handle all of this clientside but understand if this is not practical. This would make it easier to show the alert and would avoid extra postbacks.

One thought...do you have to save the changes to every tab individually or can you just have a save button that saves the stuff in all of the tabs in one big go. This sounds like it would eliminate the problem altogether.


Well, I would rather make them press save before moving between tabs, but it seems like what I want to do is a pretty complicated task.

My take on tabs is that they are more designed for segmenting content and that the user can hop around with quick clientside UI control. I think this creates a better and snappier user experience. What do you gain by forcing the user to save every tab first? Sure, you can still have a save button on every tab so that the user can save their changes if they want to, but why force them to do it? It's the same as most tabbed windows in the Windows UI...you get an option to hit an Apply button to save your changes so far or continue changing settings on multiple tabs until you are ready to save.