Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Monday, March 26, 2012

Tab Control - create tab on gridview selectindexchanged - code posted

I am using ajax tab control. I want to create a new tab everytime i click on the select of the gridview. Problem is it only allows me to create 1 tab. When I click on another select in the gridview - it doesn't allow to create another tab and gives me an error.

Is there another way to do this?

protectedvoid gv1_SelectedIndexChanged(object sender,EventArgs e)

{

UserControl ucR = (UserControl)LoadControl("../test.ascx");

ucR.ID = ((GridView)sender).SelectedDataKey.Value.ToString();

TabPanel tab =newTabPanel();

tab.Controls.Add(ucR);

tab.HeaderText = ((GridView)sender).SelectedDataKey.Value.ToString();

tcResults.Tabs.Add(tab);

}

After postback it loses the tabs - had to load in session and re-make the tabs in page_init


What error you are getting ?

Saturday, March 24, 2012

Tab Panels inside of a repeater?

I'm trying to create a dynamic amount of tabs and cannot place tab panels inside, is their a suggested alternative?

I just need tab like functionality.

Thanks alot!

-Ryan

Hi Ryan,

I'm not sure how are you trying to implement it with Repeater, but you can create TabPanel dynamically.

For instance:

AjaxControlToolkit.TabPanel tbpanel = new AjaxControlToolkit.TabPanel();
tbpanel.HeaderText = "Tab 01";
tbpanel.Controls.Add(new TextBox());
Label lb = new Label();
lb.Text = "Content";
tbpanel.Controls.Add(lb);
TabContainer1.Tabs.Add(tbpanel);

Hope this helps.


Thanks for the reply, that seems useful but I'm still a little confused how I should use it, basically this is what I need.

A Tab Container is created, inside is a repeater which, with each iteration, creates a tab panel and populates it.

So how would I add the stuff inside the panels (the stuff I've written in the aspx page)
Do I still databind?

Just confused where/how I should use that,

thanks!


So you want to populate the TabPanel dynamically? And the contents to be populated are different aspx pages?

TabPanel can't be used as a container for another page, unless wrapping a iframe inside it.

I would recommend you create UserControl(.ascx) for different content, and load it into the TabContainer.

For instance:

AjaxControlToolkit.TabPanel tbpanel = new AjaxControlToolkit.TabPanel();
tbpanel.HeaderText = "Tab 01";

if( .............. ){
Control c = this.LoadControl("relative path to the UserControl")
tbpanel.Controls.Add(c);
}
TabContainer1.Tabs.Add(tbpanel);

Wednesday, March 21, 2012

TabContainer and ModalPopupExtender

Hi,

my problem:

I have a TabContainer with 2 tabs. And I have a Panel to use with the ModalPopupExtender...

Now I create one ModalPopup in the first tab and a second ModalPopup in the second tab. In both tabs the Popup is fired by a ImageButtton. Both ModalPopup's have the same PopupControlID but it only works, when I use only one ModalPopup... When I use the two ModalPopups the Panel don't show; just the background is black/transparent when I clicked the ImageButon... I think the follow code describe my problem at best:

 <cc1:TabContainer ID="TabContainer1" runat="server"> <cc1:TabPanel ID="TabPanel1" runat="server"> <HeaderTemplate>Tab one</HeaderTemplate> <ContentTemplate> <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="ImageButton1" PopupControlID="Panel1" CancelControlID="CancelButton" BackgroundCssClass="modalBackground" DropShadow="True" DynamicServicePath="" Enabled="True" /> <asp:ImageButton ID="ImageButton1" runat="server" /> </ContentTemplate> </cc1:TabPanel> <cc1:TabPanel ID="TabPanel2" runat="server"> <HeaderTemplate>Tab two</HeaderTemplate> <ContentTemplate><%--<cc1:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="ImageButton2" PopupControlID="Panel1" CancelControlID="CancelButton" BackgroundCssClass="modalBackground" DropShadow="True" DynamicServicePath="" Enabled="True" />--%> <asp:ImageButton ID="ImageButton2" runat="server" /> </ContentTemplate> </cc1:TabPanel> </cc1:TabContainer> <asp:Panel ID="Panel1" runat="server" Height="400px" Width="400px" BackColor="white"> <h1>Here's my Popup!</h1> <asp:Button ID="CancelButton" runat="server" Text="Cancel" /> </asp:Panel>
 Now, when you comment out the "ModalPopupExtender2" you will see, the Popup is doesn't show (in both tabs)...


Is there no solution for this problem?


You could try to "work around" it, by:

- create another hidden button (style="display:none;"... )

- use that hidden button as the targetcontrolID.

- in the ImageButton1 and ImageButton2 click events, use the ModalPopupExtender1.Show() and ModalPopupExtender2.Show()

- to close the popup, same way using the.Hide()

(-->I would recommend just creating two popup panels, even if they are identical in content.. )


Yeah, but in this way I have a Postback...


Use updatepanels to avoid the full postback..