views:

671

answers:

1

Hello all,

I've finally figured out how to make all my millions of tabs (not that many really) wrap properly. Now, I want to fire a server side event whenever someone clicks on a tab. After some thorough Google searching, I thought I had struck pure gold with this:

This stuff is in the header of my aspx page:

<script type="text/javascript">
 function TABChassisFunction() {
     alert('moooo!');
     document.getElementById('BUTChassis').click();
 }
</script>

This stuff is in the body of my aspx page:

 <cc1:TabContainer ID="TabContainer1" Height="90"  runat="server" AutoPostBack="false" >
    <cc1:TabPanel ID="TABchassis" runat="server" HeaderText="Chassis" OnClientClick="TabChassisFunction();" >
        <ContentTemplate>

        </ContentTemplate>
    </cc1:TabPanel>
    <cc1:TabPanel ID="TABpowersupply" runat="server" HeaderText="Power Supply" >
        <ContentTemplate>

        </ContentTemplate>
    </cc1:TabPanel>
     <cc1:TabPanel ID="TABmotherboard" runat="server" HeaderText="Motherboard">
        <ContentTemplate>

        </ContentTemplate>
    </cc1:TabPanel>
</cc1:TabContainer>

I only put the javascript function in the first tab for testing purposes, as it looked like it should fire a hidden button I had:

Protected Sub BUTchassis_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BUTchassis.Click
    MsgBox("The server side event fired!!")
End Sub

<asp:Button ID="BUTchassis" runat="server" Text="Chassis"  CssClass="cantseeme" />

The cssclass of "cantseeme" is simply display:none;

UPDATE! I fixed my issue where the tabs vanish on me. The first attempted answer to my question was very close, I added a (); to the OnClientClick function to make it work. I have updated the above code. New problem though, it still won't fire the server side event. The javascript alert will fire, but the sub in my code behind that should display a msgbox never happens...?

Edit: If it helps any, here is the link where I got the idea to try all the above goodness: http://forums.asp.net/t/1195064.aspx

A: 

I would try changing

TabChassisFunction

to:

TabChassisFunction();

I think it takes a script here, rather than just a function name. Could it be that just the function name gets spit out into the output html rather than a valid script? If this in turn were to corrupt some of the page's other javascript, that could cause the symptoms that you are seeing. Ok, so I'm just guessing... :)

jsight
Just tested it, no dice. But it was worth a shot! I wish it were that easy ;)
Bill Sambrone
Is there any way that we can see the full output html of the broken (and non-broken) versions?
jsight