dcsimg
Results 1 to 4 of 4

Thread: [RESOLVED] A difference in page loading from a Javascript function?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,832

    Resolved [RESOLVED] A difference in page loading from a Javascript function?

    I have an aspx form that contains an IFrame. This IFrame holds a new aspx page of information along with a single parameter. I also have an image link that when clicked will load the exact same page along with the same single parameter value on a new Tab. The only difference is, the page in the IFrame loads that data into all the appropriate fields. The page loaded into a new Tab loads the page, however, the data is missing in the fields. Any idea what would cause this? Below is my code.

    Code:
        <script type="text/javascript">
            function LoadToolEdit() {
                var ftnNO = document.getElementById("hiddenFTN").value;
                var src = "Apps/ToolLists/ToolEdit.aspx?FTN=" + ftn;
                document.getElementById("iFrameTool").src = "Apps/ToolLists/ToolEdit.aspx?FTN=" + src;
            }
    
            function NewToolPage() {
                var ftnNO = document.getElementById("hiddenFTN").value;
                window.open("Apps/ToolLists/ToolEdit.aspx?ftn=" + ftnNO, "_blank");
            }
        </script>
    Code:
            <h3>Tool Edit</h3>
            <asp:UpdatePanel ID="UpdatePanel6" runat="server">
                <ContentTemplate>
                    <asp:Panel ID="pHeader6" runat="server" CssClass="cpHeader" style="border: 1px solid yellow">
                        <a onclick="LoadToolEdit()"><asp:Label ID="lblText6" runat="server" Text="" /></a>
                    </asp:Panel>
    
                    <asp:Panel ID="pHeader7" runat="server" CssClass="cpHeader" style="border: 1px solid red; width: 30px; right: 30">
                        <a onclick="NewToolPage()"><asp:Image ID="Image4" AlternateText="Image3" Width="10px" Height="10px" runat="server" CssClass="fa fa-newspaper" style="border: 1px solid blue"/></a>
                    </asp:Panel>
        
                    <asp:Panel ID="pBody6" runat="server" CssClass="cpBody">
                        <iframe id="iFrameTool" scrolling="yes" frameborder="0" width="100%" height="800px" runat="server" ></iframe>
                    </asp:Panel>
    
                    <ajaxToolkit:CollapsiblePanelExtender ID="CollapsiblePanelExtender6" runat="server" TargetControlID="pBody6" CollapseControlID="pHeader6" ExpandControlID="pHeader6"
                        Collapsed="true" TextLabelID="lblText6" CollapsedText="<i class='fa fa-plus'>" ExpandedText="<i class='fa fa-minus'>" CollapsedSize="0">
                    </ajaxToolkit:CollapsiblePanelExtender>
                </ContentTemplate>
            </asp:UpdatePanel>
    Blake

  2. #2
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    399

    Re: A difference in page loading from a Javascript function?

    So the result of LoadToolEdit() works, and the result of NewToolPage() doesn't work?

    Looking at your code, I would have assumed the opposite is true, and here's why I say that. (NOTE: I haven't done much JavaScript in many, many years, so maybe I'm misreading things)


    Code:
            function LoadToolEdit() {
                var ftnNO = document.getElementById("hiddenFTN").value;
                var src = "Apps/ToolLists/ToolEdit.aspx?FTN=" + ftn;
                document.getElementById("iFrameTool").src = "Apps/ToolLists/ToolEdit.aspx?FTN=" + src;
            }
    So you are setting ftnNO equal to the value of the hiddenFTN element. But then you are setting src equal to the specified string concatenated with the value in the ftn variable, rather than the ftnNO variable. Since no posted code references the ftn variable, presumably ftn contains nothing. So, I'm going to assume that src = "Apps/ToolLists/ToolEdit.aspx?FTN=". BUT THEN you are setting the iFrameTool source page equal to a URL that concatenates a specified string with the value in the src variable. So, as I read it, the (relative) URL that the iFrameTool frame is set to will be

    "Apps/ToolLists/ToolEdit.aspx?FTN=Apps/ToolLists/ToolEdit.aspx?FTN=", and I can't imagine that your code is written to expect that.

    I would have assumed that the code should look something like this:

    Code:
            function LoadToolEdit() {
                var ftnNO = document.getElementById("hiddenFTN").value;
                var src = "Apps/ToolLists/ToolEdit.aspx?FTN=" + ftnNO;
                document.getElementById("iFrameTool").src = src;
            }

    Aside from all that, you would probably need to post the code from your ToolEdit.aspx file, since that is where the population of that page is taking place. Perhaps the parameter passed in the URL isn't being properly handled.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,832

    Re: A difference in page loading from a Javascript function?

    OptionBase1,

    I fixed it and I'm not sure how because I see what you're talking about. I'm not sure where the variable "ftn" is as opposed to "ftnNO". Somehow the correct value is in the variable "ftn" and it's doing what it should do. I still need to track down why it's working the way it is. Thanks for your input!
    Blake

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,832

    Re: A difference in page loading from a Javascript function?

    OptionBase1,

    I fixed it and I'm not sure how because I see what you're talking about. I'm not sure where the variable "ftn" is as opposed to "ftnNO". Somehow the correct value is in the variable "ftn" and it's doing what it should do. I still need to track down why it's working the way it is. Thanks for your input!
    Blake

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width