Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 4th, 2008, 07:02 PM
Authorized User
 
Join Date: Oct 2008
Location: , , .
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
Default How to control selected MenuItem programatically

Hi Everybody,

I have a form with multi-tabs. I put a "Next" button on "Tab 1", when user cleck "Next", I would like to display "Tab 2" and its content.
In the click event on the "Next" button, I have something like:
protected void btnNext_Click(object sender, EventArgs e)
    {
        multiTabs.ActiveViewIndex = 1;
        menuTabs.TabIndex = 1;
    }

This will display the content from tab2, but the tab title still remain "Tab 1" not "Tab 2". I think what I need is also to set the <asp:MenuItem Text="Tab 2"> selected property to TRUE.
Is anyone have any idea how to set the selected property of a MenuItem? Or is there any other way to make it works? Thanks for your help.


*multiTabs is MultiView control.
 menuTabs is Menu control.

Below is the HTML codes:

<body>
    <form id="form1" runat="server">
    <div>

    <asp:Menu
        id="menuTabs"
        CssClass="menuTabs"
        StaticMenuItemStyle-CssClass="tab"
        StaticSelectedStyle-CssClass="selectedTab"
        Orientation="Horizontal"
        OnMenuItemClick="menuTabs_MenuItemClick"
        Runat="server">
<StaticSelectedStyle CssClass="selectedTab"></StaticSelectedStyle>

<StaticMenuItemStyle CssClass="tab"></StaticMenuItemStyle>
        <Items>
        <asp:MenuItem
            Text="Tab 1"
            Value="0"
            Selected="true" />
        <asp:MenuItem
            Text="Tab 2"
            Value="1"/>

        </Items>
    </asp:Menu>

    <div class="tabBody">
    <asp:MultiView
        id="multiTabs"
        ActiveViewIndex="0"
        Runat="server">
        <asp:View ID="view1" runat="server">

        <asp:Panel ID="Panel1" runat="server">
          content tab 1

            <br />

            <asp:Button ID="btnNext" runat="server" Text="Next" onclick="btnNext_Click" />
            <br />

         </asp:Panel>

        </asp:View>
        <asp:View ID="view2" runat="server">

          Content Tab 2
        </asp:View>

    </asp:MultiView>
    </div>

    </div>

    </form>
    </body>

Reply With Quote
  #2 (permalink)  
Old November 5th, 2008, 05:34 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

How is this related to the book Beginning ASP.NET 3.5? If it isn't, you're better off posting in a more generic ASP.NET category here at P2P.

If it is related, can you specify the chapter you're working on?

BTW, TabIndex is not what you think it is: http://msdn.microsoft.com/en-us/libr....tabindex.aspx

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old November 5th, 2008, 06:12 PM
Authorized User
 
Join Date: Oct 2008
Location: , , .
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Imar...sorry about that. No, you don't have a specific example on your book, you just mention MUltiView control briefly on Chap 4.

Sorry again, I guess I post the question on the wrong section, I was un-aware it's not allow:(

Reply With Quote
  #4 (permalink)  
Old November 6th, 2008, 08:09 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi melania,

It's not about "allowed or not"; it's about effective use of the forums for you and others.

People come to the book's forum for book related questions. The more on-topic posts, the easier it is for them to find relevant messages. At the same time, by posting general questions in a general ASP.NET forum, you benefit as well, as more people are likely to see and answer your posts.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #5 (permalink)  
Old November 6th, 2008, 03:08 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Just tried out your sample code (finally had the time to do so), but I am not sure what the problem is. In both cases, I see

Tab 1 Tab 2

at the top of the page.

What exactly are you trying to do? Why don't you just add a label for the title *in* the tab?

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #6 (permalink)  
Old November 7th, 2008, 03:25 PM
Authorized User
 
Join Date: Oct 2008
Location: , , .
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Imar, thanks for your help.

Anyway, I am using Menu control for the "tab title" and MultiView for the "tab content".
I have Menu control "OnClick" handler:
 protected void menuTabs_MenuItemClick(object sender, MenuEventArgs e)
    {
        multiTabs.ActiveViewIndex = Int32.Parse(menuTabs.SelectedValue);
    }

so, when you click on the "tab 1" or "tab 2", it works perfectly.

I am doing a kind of "survey" and collect information(using Wizard control), on content of tab 1 and tab 2.
I thought, it will be nice if user reach the bottom of the page, click "Finish" or "Next" button, and it will bring the user to tab2 and its content. I can achieve this by clicking the "tab title" on the top.
But when I click on the "next" button from "tab 1", the tab content was changed to the tab 2 content, which what I want. But the title, remain "Tab 1". And by clicking "Next" button, I can store user input from Tab 1 content into a database.

Thank you again for your help:)

Reply With Quote
  #7 (permalink)  
Old November 8th, 2008, 02:17 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

What I don't understand is why you're doing this with a Menu control. You usually use a menu to navigate between pages.

IMO, the Wizard control is much more suitable for this task.

But you haven't answered my question (or I didn't understand your answer): why don't you make the title part of the View or WizardStep?

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #8 (permalink)  
Old November 10th, 2008, 01:16 PM
Authorized User
 
Join Date: Oct 2008
Location: , , .
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Imar,

Actually I did try using wizard control, but the problem was I have to ended-up with "nested wizard", because I have 3 steps of surveys, each step, I have another survey with different topic.

When I was using "nested wizard" control, what I did was, the 1st wizard control for the "steps", and in the 2nd and 3rd step, I yet have another wizard control (called it wizard control 2-for 2nd step survey and 3-for 3rd step survey).

My problem was, I was not be able to "disable" the "next" button from wizard 1, before user filled out the survey on step 2 or 3(to force user to complete 2nd survey" before click "next" for the next survey.(Does it make any sense?). That's why I was stucked.

And that's why I was looking for "muti-tabs" solution, that way, I don't have the "nested wizard control" problem.

If not using MultiView + Menu control combination to achieve "multi-tabs" looks and feel, then how do usually people do the "multi-tabs"? Thanks again:)

Reply With Quote
  #9 (permalink)  
Old November 13th, 2008, 12:42 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

There are different ways. Like I said, you could add the tabs to the panels /view so they show up when the tab is active.

Otherwise, you could have Link/Image buttons that show the correct tabs when clicked.

I think you could make it work with a customized TreeView; it just means a lot of programming.

Sorry I can't help you much more. It's pretty difficult for me to suggest something useful based on the things you have explained and the code you've shown.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #10 (permalink)  
Old November 13th, 2008, 12:54 PM
Authorized User
 
Join Date: Oct 2008
Location: , , .
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thank you so much for your help Imar.

I'll try your suggestions to tackle this problem.
Thanks again for your help:)

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to update a selected row from gridview control ryan.webb ASP.NET 2.0 Professional 1 December 28th, 2007 05:21 AM
Programatically manipulating Access control List suhelahmed C# 2005 3 August 30th, 2006 01:19 PM
add menuitem in excel using VB jazzyJan Excel VBA 1 December 25th, 2005 03:34 AM
selected value from dropdownlist control netwizard_01 ASP.NET 1.0 and 1.1 Basics 3 January 20th, 2004 09:29 AM



All times are GMT -4. The time now is 06:27 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.