code to change url on another frame? or code to click the hyperlink object?

Posted on 2005-04-08
Last Modified: 2010-04-07
Hi -

I have a frame page top frame, and bottom frame
on the top frame I have a drop down box
It has a few webpages listed in it.
I'd like to load the webpage in the bottom frame when it's selected.

I have a sub Dropdownlist1_selectedindexchanged(..)

what would I put inside that?

So far my page only imports System.web.UI.Page - and I didnt see any frame targeting code in the object browser.


on another note, I tried to include a hyperlink on the top frame, that works just fine and launches the page I want in the lower frame.

Could my selectedindexchanged() sub call the hyperlink somehow? I tried hyperlink1 but VS2003 underlines it in blue - doesn't know what I'm talking about.

- Jack
Question by:fruhj
    LVL 17

    Expert Comment

    You'll need to use a javascript solution instead, as has no influence on link target's from codebehind

    See as an example.

    Please not that you can ofcourse generate this javascript from the codebehind if you wanted to.
    LVL 5

    Assisted Solution

    write the following code in selectionchanged event:-

             string script   = "<SCRIPT>"
                      script += " document.Frame2.location.href = 'your page.htm'";
                      script += "</SCRIPT>";

    so, this script will be executed while the selection is changed.
    plz post here if this is works out for your requirement.

    Vadivel Kumar
    LVL 12

    Author Comment

    Thanks both of you guys so far, I'm aware I can get some javascipt to do the work - had been wondering if this was supported directly by the .net framework - looks like it's not.

    Vadivhere - can you clarify a bit

    the page.registerclientscriptBlock("selection", Script);
    what does "selection" refer to - if my control was called DropDownList1, what do I need to do to ensure that the client javascript you put in gets executed on a change event, instead of posting back to the server?
    LVL 26

    Accepted Solution

    So i assume that u have a dropdowlist1 which has the value set as the page name where u want to navigate and the text set as the name that has to be displayed to the user .. if so add this line in the load of the page ..
    dropdownlist1.attributes.add("Onchange", "javascript:LoadNewPage();")
    .. this will call a function on the client-side (browser) whenever the selection in the dropdown changes .. remeber to set the autopostback property of the dropdown to "false"

    in the aspx page add the new function
    <script language = "javascript">
    function LoadNewPage()
       top.frames("bottomFrameName").location.href = document.getElementById("DropDownList1").value;

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now