Solved

reloading a frame within a listbox SelectedIndexChanged event?

Posted on 2004-09-20
10
580 Views
Last Modified: 2006-11-17
Hi There,

I was wondering how I can reload a frame within a listtbox SelectedIndexChanged event? I have tried the code below and it does not seem to work at all, could someone helkp me out with the syntax please?

Sean - thanks in advance


Public Sub lstStates_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstStates.SelectedIndexChanged

        Label1.Text = lstStates.SelectedItem.Value
        Response.Write("<Script language='javascript'>window.parent.document.frames(1).location.href='sidemenu.aspx';</script>")
    End Sub
0
Comment
Question by:bullrout
  • 4
  • 3
  • 3
10 Comments
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 12108678
Try using Register script..
            Dim ScriptStr As String = "<Script language='javascript'>window.parent.document.frames(1).location.href='sidemenu.aspx';</script>"
            Page.RegisterStartupScript("MyScript", ScriptStr)

-Baan
0
 
LVL 5

Author Comment

by:bullrout
ID: 12108865
Hey Baan,

I tried this but it does not seem to work at all, do you have any other ideas?

Sean
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 12108921
Is your script alright ?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 6

Expert Comment

by:viola123
ID: 12109086
this should work:

Public Sub lstStates_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstStates.SelectedIndexChanged
        Label1.Text = lstStates.SelectedItem.Value
        Response.Write("
                               <Script language='javascript'>
                                       window.parent.document.frames(1).src='sidemenu.aspx';</script>")
End Sub


cheers
viola
0
 
LVL 6

Expert Comment

by:viola123
ID: 12109092
alternatively,

i often implment the frame reload in this way:

let's say that you have a frame like this: <iframe id="myMenuFrame" src="initMenu.aspx"></iframe>

Public Sub lstStates_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstStates.SelectedIndexChanged
        Label1.Text = lstStates.SelectedItem.Value
        Response.Write("
                               <Script language='javascript'>
                                       top.myMenuFrame.src='sidemenu.aspx';</script>")
End Sub

that is my normal way to reference a frame

cheers
viola
0
 
LVL 6

Expert Comment

by:viola123
ID: 12109096
sorry, i forget to reload it ,please check this code in my project:

            var oFrame = document.getElementById("frameActiveCart");
            if (oFrame != null)      {
                  oFrame.src = "activecart.aspx";
                  window.frames.frameActiveCart.window.location.reload();
            }

good luck

viola
0
 
LVL 5

Author Comment

by:bullrout
ID: 12109869
Hi Baan,

The function you gave me does work as I tried to change the "frames(1).src" to reload the page into another frames and it seemed to reload the frame into other target frames. I apologise, because I didn't see the page change untill I place a querystring inside the redirect and then wrote the value to a label control.

Thanks for the help, I really appreciate it, thanks to viola123 as well, however I think that Baan's solution i smore suited to my application.

Sean
0
 
LVL 5

Author Comment

by:bullrout
ID: 12109893
Sorry Baan,

One more question if possible? Could you tell me the syntax that I need to use in order to have a querystring value inside the script block?

I tried the syntax below but I returns an error.

Sean

  Dim ScriptStr As String = "<Script language='javascript'>window.parent.document.frames(1).location.href='sidemenu.aspx?id=<%=strList1%>';</script>"
        Page.RegisterStartupScript("MyScript", ScriptStr)
0
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 500 total points
ID: 12111411
concate it..

 Dim ScriptStr As String = "<Script language='javascript'>window.parent.document.frames(1).location.href='sidemenu.aspx?id=" & strList1.SelectedItem.Value & "';</script>"
        Page.RegisterStartupScript("MyScript", ScriptStr)

-Baan
0
 
LVL 5

Author Comment

by:bullrout
ID: 12118270
Hi Baan,

Thanks for that, it worked like a treat.

Sean
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

792 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