Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends, i am using ajax tab panel control for tabbing in one of my form.
I have stored the form data in database and manage the status(IsComplete) for each tab form.
At page loading i have checked the tab form status (Iscomplete = true/false) and if it is true then i have to change the css class for that tab.

I have applied css class dynamically from code behind but it is not applying.
My code is :

tbpnl_general.Attributes.Add("class", "ajax__tab_tab complete"); //1st way
tbpnl_general.CssClass = "ajax__tab_tab complete"; //2ed way

but both of code are not applying any class.


My ajax tab panel code is :

<ajax:TabContainer ID="TabContainer1" runat="server" CssClass="fancy fancy-green">

XML
<ajax:TabPanel ID="tbpnl_general" runat="server" Visible="false">
                <HeaderTemplate>
                    Publish
                </HeaderTemplate>
                <ContentTemplate>
                    <asp:Panel ID="pnl_Publish" runat="server">
                        <table width="100%" align="center" style="margin: 50px 0;">
                            <tr>
                                <td>
                                    <asp:LinkButton ID="LiPublished" runat="server" OnClick="LiPublished_Click"><img alt="" src="images/publish.png" /></asp:LinkButton>
                                    <%--<asp:ImageButton ID="LiPublished" runat="server" OnClick="LiPublished_Click" ImageUrl="~/images/publish.png" AlternateText="Publish" />--%>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </ContentTemplate>
            </ajax:TabPanel>

</ajax:TabContainer>





my css class resides in css file...

Thanks
Sunil Sharma
Posted
Updated 15-Jul-14 23:07pm
v3
Comments
j snooze 15-Jul-14 17:19pm    
I'm confused. Do you know if its even getting to the code that sets the CSSClass? If your code is indeed what you have copy pasted here the biggest issue is that your tab panel is named "tbpnl_Publish" in the xhtml markup and in your code behind you call it "tbpnl_general". I'd fix that before worrying about the css. If this was not caught through debugging then I'd also recommend some good try catch statements around your code so you can tell when it errors. I use it all the time. My code is no where near perfect...so I need it.
sonusharma65 16-Jul-14 5:11am    
sorry, i have multiple tab panels. I have forgot to change the name in copy paste of code snippet . but this is not important, the important thing is how to apply css class in tab panel from code behind. you can put your own tab panel name in code and design.
akshay25101988 16-Jul-14 6:29am    
better u go wit jquery for that its very simple to change css from jquery
sonusharma65 17-Jul-14 0:59am    
can you provide me code sample to change css for tab panel according to my condition...?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900