简体   繁体   English

使用Java的DIV的导航问题。 使用VS2013和VB构建的项目

[英]Navigation problems with DIVs using Javascript. Project built using VS2013 and VB

Hey I was looking for some help as I have a problem with my navigation on my application. 嘿,我在寻求帮助,因为我的应用程序导航出现问题。 Basically the site is split up into Divs and there is a save/next button that should take the user onto the next Div (screen). 基本上,该站点分为Divs,并且有一个save / next按钮,应将用户带到下一个Div(屏幕)。 The client side event is JavaScript. 客户端事件是JavaScript。 The problem is that the whole application appear on the screen when I click the button instead of just the single screen. 问题是,当我单击按钮时,整个应用程序出现在屏幕上,而不仅仅是单个屏幕。 Could someone advise on how to hide the other Divs so only the current one is shown. 有人可以建议如何隐藏其他Divs,以便仅显示当前Divs。 My main div is called divOverview then my next screen is called divContactDetails then etc etc for another 9 screen(divs). 我的主div称为divOverview,然后下一个屏幕称为divContactDetails,然后依次类推,以此类推,另外9个屏幕(divs)。 Thanks 谢谢

     <dx:LayoutItem ColSpan="1" ShowCaption="False">
            <LayoutItemNestedControlCollection>
                <dx:LayoutItemNestedControlContainer runat="server" Width="100%">
                    <dx:ASPxButton ID="btnSave" runat="server" AutoPostBack="False" Text="Save/Next" Theme="Office2010Blue" OnClick="btnSave_Click">
                        <ClientSideEvents Click="function(s,e) {javascript:showonlyonev2('divContactDetails');}" />
                    </dx:ASPxButton>
                </dx:LayoutItemNestedControlContainer>
            </LayoutItemNestedControlCollection>
        </dx:LayoutItem>

The on_click with the save button here is the VB code behind 带有保存按钮的on_click是后面的VB代码

        If FocusSet = True Then
            ErrDetails.ForeColor = Drawing.Color.Red
            ErrDetails.Height = 20 * errCount
            ' Show the Overview screen at the beginning
            If (Not ClientScript.IsStartupScriptRegistered("showonlyonev2")) Then
                Page.ClientScript.RegisterStartupScript _
                (Me.GetType(), "showonlyonev2", "showonlyonev2('divContactDetails');", True)
            End If
            If (Not ClientScript.IsStartupScriptRegistered("showonlyonev2")) Then
                Page.ClientScript.RegisterStartupScript _
                (Me.GetType(), "showonlyonev2", "showonlyonev2('divContactDetails');", True)
            End If
            Return
        End If

JavaScript code(edit): JavaScript代码(编辑):

               <script type="text/javascript">
    function showonlyonev2(thechosenone) {
        var newboxes = document.getElementsByTagName("div");
        for (var x = 0; x < newboxes.length; x++) {
            name = newboxes[x].getAttribute("class");
            if (name == 'newboxes-2') {
                if (newboxes[x].id == thechosenone) {
                    if (newboxes[x].style.display == 'block') {
                        newboxes[x].style.display = 'none';
                    }
                    else {
                        newboxes[x].style.display = 'block';
                    }
                } else {
                    newboxes[x].style.display = 'none';
                }
            }
        }
    }

I seemed to have fixed the visibility issue. 我似乎已经解决了可见性问题。 I simple removed the second part of the VB code..... 我简单地删除了VB代码的第二部分。

        If (Not ClientScript.IsStartupScriptRegistered("showonlyonev2")) Then
            Page.ClientScript.RegisterStartupScript _
            (Me.GetType(), "showonlyonev2", "showonlyonev2('divContactDetails');", True)
        End If
        Return
    End If

Now the navigation is better but now getting Null References on other code. 现在导航更好,但现在在其他代码上获得了空引用。 The joys of programming! 编程的乐趣!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM