SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiview not quite right

    I have a page which uses a MultiView, by default the page content is displayed, I have a search field on the page which when triggered displays the results in the second view.

    Here is the problem: when the page loads it loads the contents correctly, then you type your search into the searchbox and click the button - the page refreshes but still shows the first view, when you click the button a second time it then refreshes to show the correct second view.

    Here's the code:

    <asp:MultiView ID="HomeMultiView" runat="server" ActiveViewIndex="0" OnActiveViewChanged="HomeMultiView_ActiveViewChanged">
    <asp:View ID="ContentView" runat="server">

    content here...

    </asp:view>

    <asp:View ID="SearchView" runat="server">

    search results (gridview) here

    </asp:View>

    Thanks for your help

    Kevin

    </asp:MultiView>

  2. #2
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you show the code which triggers the second view, as well as the code in Page_Load?

  3. #3
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As requested

    <script runat="server">
    Sub SwitchView(ByVal s As Object, ByVal e As EventArgs)
    HomeMultiView.ActiveViewIndex = _
    (HomeMultiView.ActiveViewIndex + 1) Mod 2
    End Sub

    Protected Sub HomeMultiView_ActiveViewChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    End Sub
    </script>

  4. #4
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, but where do you call SwitchView from?

    Also, It may be a better idea to set the view explicitly instead of just toggling it. Use HomeMultiView.SetActiveView(SearchView) to set it without relying on its index.

  5. #5
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help, I've found the problem, I had the SearchTextBox set to AutoPostBack. Doh.

  6. #6
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by honeymonster View Post
    Yeah, but where do you call SwitchView from?

    Also, It may be a better idea to set the view explicitly instead of just toggling it. Use HomeMultiView.SetActiveView(SearchView) to set it without relying on its index.
    Does using this code mean I won't have to click button to trigger searchview? I would like users just to be able to hit return when they've typed their search.
    If so where does the code go? I'm sure the answer's simple but I'm new to VB.

    Many thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •